Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the purpose of the Newtonsoft.Json.JsonToken.StartConstructor token?

The JsonToken enum in Newtonsoft.Json namespace contains, among others, the entry JsonToken.StartConstructor.

I most likely misinterpret the meaning of this token, as I take it for granted that JS's constructor methods are not valid in JSON, the same as there are no function, expression, or var tokens.

So how would a constructor be manifested in JSON, if that's what it is?

like image 986
Tar Avatar asked Feb 10 '17 11:02

Tar


1 Answers

Looking at the ParseTests source code, it looks like it's so that you can have JSON like this:

{ "date": new Date(2017, 2, 10) }

... which isn't actually valid JSON, but may be common in the wild.

like image 92
Jon Skeet Avatar answered Sep 28 '22 05:09

Jon Skeet