↧
Answer by StriplingWarrior for Safe JSON navigation
For the exact syntax you mention, you can cast your JObject as dynamic.var jObj = JsonConvert.DeserializeObject<dynamic>(text);string value1 = jObj.foo?.bar?.baz ?? "default";Here's a LINQPad...
View ArticleSafe JSON navigation
Is there a way to navigate a JSON safely?Given this JSON,{"foo": { "bar": { "baz": "quz" } } }I'd like to navigate it safely similar to the line below without creating types for all of them.string...
View Article