Rotem B
Rotem B

Reputation: 1377

Parsing JValue to either JObject or JArray

Is there a nice way to get a json value, using var myValue = json["prop"] and insert it to a common object/interface? The value could be a json {} or an array []. I know I can insert them to a JObject and JArray, but is there a common object?

I also want to know (maybe the same answer to the above), if I can parse json from string, when again, I don't know if it's an array or an object.

Upvotes: 2

Views: 7676

Answers (1)

StriplingWarrior
StriplingWarrior

Reputation: 156524

The JToken type is a common base type for JObject and JArray. It is what json["prop"] would return, and if you had a JToken of either type, then you could set json["prop"] = token.

Upvotes: 7

Related Questions