When parsing from an object
to JObject
you can specify a JsonSerializer
which instructs how to handle dates.
JObject.FromObject(new { time = s },
new JsonSerializer {
DateParseHandling = DateParseHandling.None
});
Unfortunately Parse
doesn’t have this option, although it would make sense to have it. Looking at the source for Parse
we can see that all it does is instantiate a JsonReader
and then passes that to Load
. JsonReader
does have parsing options.
You can achieve your desired result like this:
using(JsonReader reader = new JsonTextReader(new StringReader(j1.ToString()))) {
reader.DateParseHandling = DateParseHandling.None;
JObject o = JObject.Load(reader);
}