Created
April 25, 2019 15:33
-
-
Save jskeet/3fa65c63fcc4a8235c8d3d5a5b985f46 to your computer and use it in GitHub Desktop.
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
| using System; | |
| using Newtonsoft.Json; | |
| public class Item | |
| { | |
| public string Name { get; set; } | |
| public DateTime Date { get; set; } | |
| } | |
| class Test | |
| { | |
| static void Main() | |
| { | |
| JsonConvert.DefaultSettings = () => new JsonSerializerSettings | |
| { | |
| DateFormatString = "dd'/'MM'/'yyyy' 'HH':'mm" | |
| }; | |
| string json = @" | |
| { | |
| 'Name': 'Test', | |
| 'Date': '13/02/2019 05:13' | |
| }".Replace('\'', '"'); | |
| var item = JsonConvert.DeserializeObject<Item>(json); | |
| Console.WriteLine(item.Name); | |
| Console.WriteLine(item.Date); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment