json.netを使用して、WebApiサービスで着信jsonを逆シリアル化しています。ポストポストマンで使用されているJSONを逆シリアル化する際にC#エラーが発生しました
The best overloaded method match for 'Newtonsoft.Json.JsonConvert.DeserializeObject<RootObject>(string)' has some invalid arguments
入力JSON::
{ "data": [
{"zipcode":"56033","line1":"610 4TH ST","city":"FROST","state":"MN","cid":"1770"},
{"zipcode":"56033","line1":"45375 30TH ST","city":"FROST","state":"MN","cid":"1771"},
{"zipcode":"56033","line1":"115 4TH ST","city":"FROST","state":"MN","cid":"1772"}
]}
POCOクラス
var lines = JsonConvert.DeserializeObject<RootObject>(json);
他の同様の回答数を読んだ後、それはまだ、このエラーを投げていますhttp://json2csharp.comを使用して作成されました。ここで
public class Datum
{
public string zipcode { get; set; }
public string line1 { get; set; }
public string city { get; set; }
public string state { get; set; }
public string cid { get; set; }
}
public class RootObject
{
public List<Datum> data { get; set; }
}
は私がAPIをデバッグするとき、私が見たものである。
{{
"data": [
{
"zipcode": "56032-0056",
"line1": "208 MAIN BOX 56",
"city": "FREEBORN",
"state": "MN",
"cid": "1732"
},
{
"zipcode": "56033",
"line1": "610 4TH ST",
"city": "FROST",
"state": "MN",
"cid": "1770"
},
{
"zipcode": "56033",
"line1": "45375 30TH ST",
"city": "FROST",
"state": "MN",
"cid": "1771"
},
{
"zipcode": "56033",
"line1": "115 4TH ST",
"city": "FROST",
"state": "MN",
"cid": "1772"
},
{
"zipcode": "56033",
"line1": "E 4TH ST",
"city": "FROST",
"state": "MN",
"cid": "1773"
}
]
}}
WEBAPIは、中括弧の余分なセットを追加したり、それらをどのように防ぐためですなぜわかりません。
誰かが私が見逃しているのを見てください。
'json'とは何ですか? –
@GillBates JavaScriptオブジェクト表記 – Sentry
@GillBates Sry、April 1st habit。 'json'はおそらくOPが" Input json "と書いたものです – Sentry