- Home /
JSON string problem
what is the word 'data' in this json string. {"data":[ {"id":7, "name":"Charminar","thumbnail":"http://placehold.it/100x50","image":"http://placehold.it/400x200"}, {"id":8, "name":"Apartment 1","thumbnail":"http://placehold.it/70x35","image":"http://placehold.it/700x350"}, {"id":9, "name":"Apartment 2","thumbnail":"http://placehold.it/80x40","image":"http://placehold.it/800x40"} ]}
Answer by Elisvaldo · Jun 05, 2015 at 07:19 AM
According to http://json2csharp.com/
public class Datum
{
public int id { get; set; }
public string name { get; set; }
public string thumbnail { get; set; }
public string image { get; set; }
}
public class RootObject
{
public List<Datum> data { get; set; }
Thank u so much for giving reply. i solved my problem with your answer once again thank u so much.
That website "json2csharp" is great; although it turns every array into a list (which is generally not as efficient)
The difference is pretty irrelevant. Also in most cases a List makes more sense unless you always only need your class to read json data. Also the page has a link to quicktype which does allow some settings.
Though when dealing with web responses I prefer my SimpleJSON parser since the response does not necessarily follow the exact structure. Object parsers like Unity's JsonUtility or Json.NET can only parse a predefined format. If a server might return different structures (error case, success case, ...) using such parsers is problematic. SimpleJSON just parses the json data and provides easy access to all the data
Your answer
