2
WebAPIから次のJson形式が返されました。あなたは民主化を助けることができますか?HttpClientを使用してWebAPIのDeseriaize Json
{
"@odata.context":"http://....... ","value":[
**{
"RecordNumber":"LDxxxx","RecordType":"Loan","PropertyAddress":{ "Address1":"601 xxxx","Address2":null,"Zip":"99999","City":"abc","State":"ab","County":"abcd" }
,"Summary":{ "BorrowerName":null,"ProductCode":null,"Status":"Not Registered" }
}**,{
"RecordNumber":"LDxxxx","RecordType":"Loan","PropertyAddress":{ "Address1":"601 xxxx","Address2":null,"Zip":"99999","City":"abc","State":"ab","County":"abcd" }
,"Summary":{ "BorrowerName":null,"ProductCode":null,"Status":"Not Registered" }
},
….]
}
私は値要素には何が必要です。太字はAPIからのリターンで繰り返されるものです。次のような記述に合ったクラスを作成しました。
public class RootObject
{
[JsonProperty(PropertyName = "RecordNumber")]
public string RecordNumber { get; set; }
[JsonProperty(PropertyName = "RecordType")]
public string RecordType { get; set; }
[JsonProperty(PropertyName = "PropertyAddress")]
public PropertyAddress PropertyAddress { get; set; }
[JsonProperty(PropertyName = "Summary")]
public Summary Summary { get; set; }
}
は、以下を使用してJSON配列の最初のレコードをスキップすることができました「バリュー」の部分を得た....が、「値」オブジェクト
var dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(forecast);
foreach (var kv in dict.Skip(1))
{
JArray jsonVal = JArray.Parse(kv.Value.ToString());
}
の取得に成功していません
あなたのお手伝いを心より感謝します。
サティヤ
が本当に正確なJSONということです(http://json2csharp.com/の助けを借りて)具体的なクラスにデシリアライズすることができますか? '**'とすべて? – maccettura
Maccettura ...いいえ、私はそれらを同じフォーマットの繰り返しを示すためにそこに置きます。 – Satya