0
所以我試圖讓這個JSON解析正確,但它只是崩潰。而http://json2csharp.com/不能給我正確的類多對象JSON到對象C#
這是JSON:
[
{
"id": "2300",
"file_name": "2300_file",
"representations": {
"thumb": "thumb.jpeg",
"small": "small.jpeg",
"medium": "medium.jpeg",
"full": "2300.jpeg"
}
},
{
"id": "2c00",
"file_name": "2c00_file",
"representations": {
"thumb": "thumb.jpeg",
"small": "small.jpeg",
"medium": "medium.jpeg",
"full": "2c00.jpeg"
}
},
{
"id": "0800",
"file_name": "0800_file",
"representations": {
"thumb": "thumb.jpeg",
"small": "small.jpeg",
"medium": "medium.jpeg",
"full": "0800.jpeg"
}
}
]
,這裏是當前代碼我使用:
public class Representations
{
public string thumb { get; set; }
public string small { get; set; }
public string medium { get; set; }
public string full { get; set; }
}
public class Picture
{
public string id { get; set; }
public string file_name { get; set; }
public Representations representations { get; set; }
}
private void button1_Click(object sender, EventArgs e)
{
Picture ImageThing = JsonConvert.DeserializeObject<Picture>(InputBox.Text); //Imputbox is where the json resides
MessageBox.Show(ImageThing.file_name);
}
所以,我怎麼能做出的MessageBox分別輸出所有三個對象的file_name?
對不起,低質量的解釋,我累了,我只是想讓這個小東西工作。
[在C#解析JSON]的可能重複(http://stackoverflow.com/questions/1212344/parse-json -in-c-sharp) – durron597