JConstructor designed to enable date capture in JavaScript Date Format , for example: new Date(1234656000000) . As noted in Date Serialization in JSON :
Technically, this is invalid JSON according to the specification, but all browsers and some JSON frameworks, including Json.NET, support it.
Thus, the JConstructor will not be displayed when parsing a JSON that strictly conforms to the current IETF standard or the original JSON clause .
JRaw will never appear when parsing JSON using JToken.Parse(string) . This is useful mainly to facilitate writing pre-formatted JSON literals from the JToken hierarchy. Using JRaw , you can avoid parsing already formatted JSON just to retrieve it, for example:
var root = new JObject(new JProperty("response", new JRaw(jsonLiteral))); var rootJson = root.ToString();
can be done instead of less efficient:
var root = new JObject(new JProperty("response", JToken.Parse(jsonLiteral)));
You can also deserialize to JRaw to grab the JSON hierarchy as a single string literal, although I don't see much point in that. For example, given the class:
public class RootObject { public JRaw response { get; set; } }
You can do:
var rootDeserialized = JsonConvert.DeserializeObject<RootObject>(rootJson); var jsonLiteralDeserialized = (string)rootDeserialized.response;
However, this is not necessarily more efficient than deserialization for a JToken .