Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Json.Net parsing datetime value error

Tags:

c#

json.net

I am trying to convert a json string to a JObject using JObject.Parse, but running into the error "Error parsing positive infinity value. Path 'Modified.Date', line 1, position 52."

Here is the part of json that is throwing the error on -

{ ..., "Modified" : { "Date" : ISODate("2013-02-21T22:23:57.118Z"), "User" : "Admin" }, ...}

Here is the code I am using to do the parse -

var jobj = JObject.Parse(formJson)

Update: The json was generated by using mongodb's .ToJson() extension method, by sending in the following jsonwritersettings it generated json that was parsable by json.net - new JsonWriterSettings { OutputMode = JsonOutputMode.JavaScript };

like image 460
camelCaseWarrior Avatar asked Dec 05 '25 13:12

camelCaseWarrior


1 Answers

I think you need to lose the ISODate.

This works:

String MyJson = "{MyDate   : \"2013-02-21T22:23:57.118Z\" }";
var x = Newtonsoft.Json.Linq.JObject.Parse(MyJson);
like image 119
Steve Wellens Avatar answered Dec 07 '25 03:12

Steve Wellens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!