Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created April 25, 2019 15:33
Show Gist options
  • Select an option

  • Save jskeet/3fa65c63fcc4a8235c8d3d5a5b985f46 to your computer and use it in GitHub Desktop.

Select an option

Save jskeet/3fa65c63fcc4a8235c8d3d5a5b985f46 to your computer and use it in GitHub Desktop.
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