josecgomez
(Jose C Gomez)
July 21, 2023, 8:58pm
71
Lookie here someone else b*tched about it
opened 12:50PM - 30 Mar 16 UTC
closed 11:25PM - 31 May 16 UTC
We're using Json.NET 8.0.2 in a C# 4.5 project, and we love it.
However this be… havior bit us pretty hard:
``` c#
var obj = JsonConvert.DeserializeObject<JObject>("{ 'x': '2016-03-31T07:02:00+07:00' }");
```
Here, in our time zone, `ob["x"].Value<string>()` returns `"2016-03-31T02:02:00+02:00"`.
The problem disappears if we specify how to parse dates:
``` c#
var obj = JsonConvert.DeserializeObject<JObject>("{ 'x': '2016-03-31T07:02:00+07:00' }",
new JsonSerializerSettings() { DateParseHandling = DateParseHandling.None });
```
But I find it _dangerously surprising_ that by default Json.NET interprets strings as dates (let alone the performance issues this inevitably brings with it).
Is this the expected behavior? If so, is there a way to disable this behavior globally?
They closed the issue as “a feature not a bug”… say… do they work for support too?
The argument is that there is no standard "date’ format for JSON so THEY Newtonsoft decided that ISO is “THE” standard and you can override it with some flags but basically if it matches the format you are SOL.
1 Like