Created
August 31, 2016 04:58
-
-
Save asith-w/22c7d1092ca372e497b311f10bc00380 to your computer and use it in GitHub Desktop.
C# -json JsonSerializerSettings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Product product = new Product | |
{ | |
ExpiryDate = new DateTime(2010, 12, 20, 18, 1, 0, DateTimeKind.Utc), | |
Name = "Widget", | |
Price = 9.99m, | |
Sizes = new[] {"Small", "Medium", "Large"} | |
}; | |
string json = | |
JsonConvert.SerializeObject( | |
product, | |
Formatting.Indented, | |
new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() } | |
); | |
//{ | |
// "name": "Widget", | |
// "expiryDate": "\/Date(1292868060000)\/", | |
// "price": 9.99, | |
// "sizes": [ | |
// "Small", | |
// "Medium", | |
// "Large" | |
// ] | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment