2017-06-17 132 views
1

通常JSON字符串自帶裹在支架像following--刪除字符串外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

問題是如何?

回答

2

您以JSONP格式而不是JSON獲得結果。使用Format=JSON參數來取代JSON。

+0

只是想出來!哈哈,你打敗了我!但是,謝謝你,先生! – envyM6