通常JSON字符串包含在括号中,如下所示 -
{
"Result":"1",
"ErrorText":"",
"Item":[{
"@value":"1",
"Postcode":"B6 4AA",
"PostcodeFrom":"",
"Key":"B6 4AA1001",
"List":"B6 4AA Royal Mail, Birmingham Mail Centre, St. Stephens Street, BIRMINGHAM", "CountryISO":"GBR"
}]
}
但由于一些奇怪的原因,我从AFD服务获得的JSON格式如下
JSON({
"Result":"1",
"ErrorText":"",
"Item":[{
"@value":"1",
"Postcode":"B6 4AA",
"PostcodeFrom":"",
"Key":"B6 4AA1001",
"List":"B6 4AA Royal Mail, Birmingham Mail Centre, St. Stephens Street, BIRMINGHAM", "CountryISO":"GBR"
}]
})
我的计划是使用json2csharp并反序列化JSON字符串,但将代码粘贴到带有JSON({})的代码上却给了我错误。所以我想我必须以某种方式摆脱字符串JSON
才能反序列化。
问题是如何?
答案 0 :(得分:2)
您获得的结果是JSONP格式而不是JSON格式。使用Format=JSON
参数来获取JSON。