首先先谢谢你,我在这方面遇到了很多麻烦。
我正在调用一个API,它以非常糟糕的格式发回JSON。数组中似乎有数组。如何将其转换为JSON对象,以便字符串为@id,值为" $"
{"cake-response-list": {
"@error": "EndOfResults",
"@throttle": "712",
"@total-cakes": "712",
"cake-responses": {
"cake.model": [
{
"@mh": "0x1111111",
"ns1.attribute": [
{
"@id": "0x22222",
"$": "ChocGateux"
},
{
"@id": "0x33333",
"$": "ChocMud"
}
]
},
{
"@mh": "0x4444444",
"ns1.attribute": [
{
"@id": "0x55555",
"$": "VanillaSponge"
},
{
"@id": "0x66666",
"$": "RaspberryCheesecake"
}
]
},
{
"@mh": "0x7777777",
"ns1.attribute": [
{
"@id": "0x88888",
"$": "ChocEclair"
},
{
"@id": "0x99999",
"$": "StrawCheesecake"
}
]
}
]
}
} }
答案 0 :(得分:0)
您可以执行类似于JSON的类,然后将JSON反序列化为它。然后像使用简单对象一样使用它。
一些对您有用的文章:
http://www.newtonsoft.com/json/help/html/SerializingJSON.htm
Deserializing JSON to .NET object using Newtonsoft (or LINQ to JSON maybe?)