Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JIL .NET JSON Deserialization exception

I run simple deserialization into own type Event with :

JSON.Deserialize<Event>(text);

with exception:

An exception of type 'Jil.DeserializationException' occurred in Jil.dll but was not handled in user code.
Additional information: Expected character: '\'

Newtonsoft's JSON deserialization works well on the same json, also JSONLint confirmed JSON is valid. Any clues here ? I tried passing in string, as well as using using(StringReader) as is suggested on JIL's github page.

like image 690
frno Avatar asked Apr 09 '15 10:04

frno


1 Answers

Without seeing the JSON-String, you try to deserialize i am not sure about this, but eventually the deserializer expects the date(time) that you're trying to deserialize to be in another format (I guess you're trying to deserialize a datetime-field).

It seems that JIL assumes, that datetimes are delivered as 'NewtosoftDateTime', but you are delivering another format. See https://github.com/kevin-montrose/Jil/blob/master/Jil/Deserialize/InlineDeserializer.cs#L667 for detailed infos, how jil assumes your date is formatted.

You can change the expected formatting via Options. See more here: https://github.com/kevin-montrose/Jil/blob/master/Jil/Options.cs

like image 116
Marvin Avatar answered Nov 16 '22 11:11

Marvin