This project has moved and is read-only. For the latest updates, please go here.

Deserialize JValue or JObject from string

Jun 16, 2010 at 7:37 PM

The Facebook REST API returns either a single JSON value in the case of success, such as "1234567_1234567" or a complex JSON object in the case of an error, such as { error_code: 100, error_msg: "Message" }

How can I use JSON.NET to deserialize the string, not yet knowing whether the result is a value or an object?

Jun 19, 2010 at 3:43 PM

You could create a JsonTextReader over the string and then call JToken.ReadFrom with the reader as a parameter.