I am seeing an exception when deserializing a JSON string that contains a JSON-serialized LocalDate object (see the end of this question for the JSON snippet).
This is how I am deserializing:
var settings = new JsonSerializerSettings();
settings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
var output = JsonConvert.DeserializeObject<MyObject>(json, settings);
I see this exception message:
NodaTime.Utility.InvalidNodaDataException: 'Unexpected token parsing LocalDate. Expected String, got StartObject.'
This the MyObject class:
class MyObject
{
public LocalDate Date { get; set; }
public string AnotherProperty { get; set; }
}
Here is the JSON snippet I'm trying to deserialize:
{
"Date": {
"Calendar": {
"Id": "ISO",
"Name": "ISO",
"MinYear": -9998,
"MaxYear": 9999,
"Eras": [{
"Name": "BCE"
}, {
"Name": "CE"
}]
},
"Year": 2017,
"Month": 7,
"Day": 10,
"DayOfWeek": 1,
"YearOfEra": 2017,
"Era": {
"Name": "CE"
},
"DayOfYear": 191
},
"AnotherProperty": "A string"
}