I have some Json response from server, for example:
{"routes" : [
{
"bounds" : {
"northeast" : {
"lat" : 50.4639653,
"lng" : 30.6325177
},
"southwest" : {
"lat" : 50.4599625,
"lng" : 30.6272425
}
},
"copyrights" : "Map data ©2013 Google",
"legs" : [
{
"distance" : {
"text" : "1.7 km",
"value" : 1729
},
"duration" : {
"text" : "4 mins",
"value" : 223
},
And I want to get the value of token 'text' from
"legs" : [
{
"distance" : {
"text" : "1.7 km",
"value" : 1729
},
which is string with value "1.7 km".
Question: is there any build-in function in NewtonsoftJson lib which can be look like:
public string(or JToken) GetJtokenByName(JObject document, string jtokenName)
or do I need to implement some recursive method which will search JToken by name in all JTokens and JArrays in JObject?