- Home /
Question by
Delfuego · Jan 15, 2015 at 05:41 AM ·
jsondeserialize
Deserializing JSON
Hello! I have json with list of friends and information about that from vk.com api:
response: {
count: 262,
items: [{
id: 38097687,
first_name: 'Aida',
last_name: 'Fazy',
online: 1
}, {
id: 4261331,
first_name: 'Aisa',
last_name: 'Red',
online: 0
}, {
id: 35630046,
first_name: 'Alex',
last_name: 'Feer',
online: 1
}]
}
How can I Debug.log each friend first_name + last_name using any JSON lib for parsing? I tried several hours to do that and still no progress becaurse lack of knowledge :(
Comment
Answer by Cocobongo · Jan 15, 2015 at 09:03 AM
My preference when working with JSON is Boomlagon's plugin (that's in C#). It's free and does the work.
You would then do something like:
string json = "...";
var parsedJson = JSONObject.Parse(json);
var items = parsedJson["response"].Obj["items"].Array;
for(var i = 0 ; i < items.Length ; ++i) {
Debug.Log(items[i].Obj["first_name"].Str);
}