Reputation: 719
{
"albums": [
{
"name": "Muse",
"permalink": "Muse",
"cover_image_url": "http://image.kazaa.com/images/69/01672812 1569/Yaron_Herman_Trio/Muse/Yaron_Herman_Trio-Muse_1.jpg",
"id": 93098,
"artist_nam e": "Yaron Herman Trio"
},
}
How do i get the value of 'name' contained in 'album'? Please help! Are there any specific ways to do it? Looked through the api and tried but stuck at retrieving the value!
Upvotes: 2
Views: 5575
Reputation: 1
Make sure your collection variable is declared public. For example:
public class Albums
{
public List<Album> albums{get;set;}
}
Upvotes: 0
Reputation: 40970
Just Deserialized your json into your object.
using JsonConvert.DeserializeObject<objectType>(jsonString);
e.g; you have a class
Public class Album
{
public string name {get;set;}
public string permalink {get;set;},
public string cover_image_url {get;set;}
public int id {get;set;}
public string artist_name{get;set}
}
another class
public class Albums
{
List<Album> albums{get;set;}
}
Then just use
var albums=JsonConvert.DeserializeObject<Albums>(jsonString);
Now albums contains the list of album objects so now you can get any value from there.
Upvotes: 2