question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add DictionaryKeyPolicy to CosmosSerializationOptions

See original GitHub issue

System.Text.Json allows consumers to specify a different naming policy for dictionary keys than for regular properties. This is supported via a DictionaryKeyPolicy property on JsonSerializerOptions. A similar capability should be provided for the out-of-the-box Cosmos serializer without having to implementing a custom serializer.

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ealsurcommented, Apr 14, 2023

I see two paths:

  1. Add a bool to the CosmosSerializationOptions to apply the NamingPolicy to Dictionaries. The problem is mixing the boolean with a NamingPolicy that would not apply (like Default).
  2. Add a new enum value to CosmosPropertyNamingPolicy, like CamelCaseOnlyProperties. This approach makes sure we set the flag in the CamelCasePropertyNamesContractResolver to false.

I’ll mark this as feature request to be tracked.

1reaction
davecluderaycommented, Apr 14, 2023

Yes, that is right. I want to be able to configure it so that dictionary keys pass through unchanged, regardless of the property naming strategy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Untitled
Add DictionaryKeyPolicy to CosmosSerializationOptions #3810 ... WebApr 27, 2022 · You could also make a JsonSerializerOptions singleton and add that to DI: ...
Read more >
JsonSerializerOptions.DictionaryKeyPolicy Property
Gets or sets the policy used to convert a IDictionary key's name to another format, such as camel-casing.
Read more >
CosmosClientOptions.Serializer Property
The client will use it to serialize or de-serialize user's cosmos request/responses. SDK owned types such as DatabaseProperties and ContainerProperties will ...
Read more >
Untitled
bsod_ Aug 24, 2018 at 21:31 Add a comment 1 Answer Sorted by: 8 Option 1 Even though Widget is ... To do...
Read more >
c# - System.Text.Json.JsonSerializer ignores ...
This is a known bug in .NET Core 3.x that has been fixed in .NET 5. See: System.Text.Json: DictionaryKeyPolicy not applied to keys...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found