I have a large JSON file similar to this:
{
"data":[
{
"attribution":null,
"tags":[
"thenight2"
],
"type":"image",
"images":{
"standard_resolution":{
"url":"http://distilleryimage3.s3.amazonaws.com/59d6984092a211e392db12e25f465f4f_8.jpg",
"width":640,
"height":640
}
}
},
{
"attribution":null,
"tags":[
"thenight2"
],
"type":"image",
"images":{
"low_resolution":{
"url":"http://distilleryimage1.s3.amazonaws.com/c179b34a91ff11e3b99c0aa73e1070c5_6.jpg",
"width":306,
"height":306
},
"thumbnail":{
"url":"http://distilleryimage1.s3.amazonaws.com/c179b34a91ff11e3b99c0aa73e1070c5_5.jpg",
"width":150,
"height":150
},
"standard_resolution":{
"url":"http://distilleryimage1.s3.amazonaws.com/c179b34a91ff11e3b99c0aa73e1070c5_8.jpg",
"width":640,
"height":640
}
},
"users_in_photo":[
]
}
]
}
I want to extract from the a list of all the url
attribute values from the standard_resolution
attribute of all the images within the JSON. How can it be done?
You can use the Linq features of JSON.net, along with the select token method to get at the data you are looking for:
Add reference
Make a string variable using JSON
Create a method inside the class in which conversion takes place.
Add these classes below the class having conversion
Place this code where you need conversion
Use foreach to loop across the variable dataObj.
Example Parsing JSON object containing an array with Windows Phone 7
I have used the JSON class in System.Web.Helpers Namespace (.Net 4.0) previously and it works well for me. You are able to refer to arrays dynamically. It should be used similarly to this: