I got some strange behavior when reading a json-file with C#.
My json-file contains some dates:
"status": "Open",
"priority": "Medium",
"created": "2013-11-13T18:40:36.000+0000",
"updated": "2014-1-2T10:45:17.000+0000",
"duedate": "2013-12-31T0:0:0.000+0000",
I read the file via
string json = File.ReadAllText(fileName)
// the following line does not matter (just for reference)
// issue already exists when viewing the json string variable above
JObject mappedObj = JObject.Parse(File.ReadAllText(fileName));
My json string now contains
"status": "Open",
"priority": "Medium",
"created": "11/13/2013 19:40:36",
"updated": "2014-1-2T10:45:17.000+0000",
"duedate": "2013-12-31T0:0:0.000+0000",
It's just the "created" field that does not behave like it should.
Interesting part: This does not only happen after deserialization, the wrong date shows up, when i view the "json" string with the .net debugging json-viewer (not with the text-viewer!). As you can see, i just display the content read from the file.
Any ideas? Interestingly the code worked before reinstalling Windows. Maybe it's some localization issue. I want my code to be localization indepentent anyway. Any suggestions would be highly appreciated :)
Follow-Up-Question
Ok, it's now obvoius that the dates, that are not converted, do not accord to ISO-standard.
Do you know if there is a way to avoid the parser recognizing the string as date? If i want to serialize again, it keeps outputting the "13.11.2013" string instead of the ISO-Notation i need.
I use
JsonConvert.SerializeObject(inforData, new IsoDateTimeConverter())