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