Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
273 stars 55 forks source link

Fixes DateTimeOffset raw deserialization issue #110

Closed Zaid-Ajaj closed 5 years ago

Zaid-Ajaj commented 5 years ago

Address #109 Ok so this was a bit dumb on the Newtonsoft.Json side of things, parsing raw strings get interpreted as dates if they look like dates and this is a default behaviour 😱

let json = "[ \"2019-04-01T16:00:00+05:00\" ]"
let parsed = JToken.Parse(json)
parsed.ToString() // [ "2019-04-01T16:00:00+02:00"] 

Luckily this can be overridden:

let json = "[ \"2019-04-01T16:00:00+05:00\" ]"
let settings = JsonSerializerSettings(DateParseHandling = DateParseHandling.None)
let parsed = JsonConvert.DeserializeObject<JToken>(json, settings)