uppercase/lowercase keys in the serialized JSON
See original GitHub issueGiven the class
public class MyClass {
public string MyField {get;set;}
public string MyOtherField {get;set;}
}
the generated JSON will be
{"MyField": "field value", "MyOtherField": "other field value"}
However, the REST API on the other end of the wire follows another naming convention where the keys are expected to be in lowercase, like
{"myField": "field value", "myOtherField": "other field value"}
Is there an easy way to achieve this without resorting to a custom serializer? It’s such a small change that preferrably it would only be a configuration switch somewhere.
Issue Analytics
- State:
- Created 11 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Ensuring json keys are lowercase in .NET
In Json.NET 9.0.1 and later it is possible to ensure that all property names are converted to lowercase by using a custom NamingStrategy...
Read more >How to serialize properties to lower case using System. ...
How to serialize properties to lower case using System.Text.Json. ... lower case amount but Serialize method returns upper case Amount .
Read more >SerializeJSON with lowercase keys and override ...
This legacy app basically provides JSON packets for a client side JS app. As such the client app is expecting all json keys...
Read more >TIL: Dictionary keys are converted to lowercase too on ...
TIL: Dictionary keys are converted to lowercase too on serialization · 1. Configure Newtonsoft.Json NamingStrategy · 2. Use a comparer in your ...
Read more >Convert JSON keys to lowercase? : r/learnpython
Where the first letter of a new word in a String for the key value is Capitalized. What I would like to do...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Use
JsonProperty
attribute on the property to specify a different name when serialized!it was not. if this feature is needed then RestSharp gives you the ability to use a custom de/serializer so you’d have to use that for now.