如何使用Xamarin.Forms中的标头和详细信息反序列化Json文件?

时间:2016-09-07 15:18:15

标签: c# json xamarin.forms deserialization

{
    "id": "007",
    "name": "James Bond",
    "missions": [{
        "year": "2006",
        "title": "Casino Royale"
    },
    {
        "year": "2008",
        "title": "Quantum of Solace"
    },
    {
        "year": "2012",
        "title": "Skyfall"
    },
    {
        "year": "2015",
        "title": "Spectre"
    }]
}

1 个答案:

答案 0 :(得分:0)

看看这个: https://components.xamarin.com/view/json.net

有了这个Libary,它真的很容易

您可以反序列化:

JamesBondObject oResult = (JamesBondObject) JsonConvert.DeserializeObject(sResponse, typeof( JamesBondObject ) );


class JamesBondObject {
    int id;
    string name;
    Mission[] missions;
}

class Mission {
    int year;
    string title;
}