私は以下のようなAPIを持っています。JSONから値を取得する方法
[
{
"name":"test1",
"commit":{
"id":"8595fad8cd84c7a630c5d7a78414f9c",
"short_id":"8595fad8",
"title":"title 1",
"created_at":"2017-05-29T07:18:36.000+00:00",
"parent_ids":[
"74956b0bcd370f3ddc75d7db00336099cce20501"
],
"message":"Update README.md",
"author_name":"Administrator",
"author_email":"email.com",
"authored_date":"2017-05-29T07:18:36.000+00:00",
"committer_name":"Administrator",
"committer_email":"email.com",
"committed_date":"2017-05-29T07:18:36.000+00:00"
},
"merged":true,
"protected":false,
"developers_can_push":false,
"developers_can_merge":false
},
......
]
私のクラスには、私は上記のすべてのバルブを取得しようとしました
protected class BranchData
{
public string Name { get; set; }
public string Merged { get; set; }
public string Protected { get; set; }
public string Authored_Date { get; set; }
}
です。しかし、私はauthored_date
の値を得ていませんでした。
私のコードは、私がauthored_date
(ヌル)を除くbranchDetails
リスト内のすべてのクラス値を取得
var jSONString = reader.ReadToEnd();
branchDetails = JsonConvert.DeserializeObject<List<BranchData>>(jSONString);
です。
どうすればこの問題を解決できますか?
「Authored_Date」は、内部オブジェクトに由来します。それを唯一のプロパティとして新しいクラスを作成し、それを 'BranchData'のプロパティとして追加します。 – willaien