MarkLogicからのJSON応答を使用して、C#のモデルにバインドしています。関連するスニペットは以下の通りです:.NET内の配列内にJSONオブジェクトをバインドする
{
"snippets":{
"match":[
{
"value":[
"In (consolidated) enforcement actions for failure to answer subpoena, appeal from ",
{
"highlight":{
"value":"judgement"
}
},
" for defendants."
]
}
]
}
}
それは二つの文字列と別のJSONオブジェクトが含まれているので、私が午前問題は、外側の「値」配列です。この配列をC#でバインドする方法はありますか?私の現在のモデルは次のようになります。
[JsonProperty(PropertyName = "snippets")]
public MarkLogicSnippetsModel Snippets { get; set; }
public class MarkLogicSnippetsModel
{
[JsonProperty(PropertyName = "match")]
public IEnumerable<MarkLogicMatchModel> Matches { get; set; }
}
public class MarkLogicMatchModel
{
[JsonProperty(PropertyName = "value")]
public IEnumerable<string> Values { get; set; }
}
しかし、配列内のオブジェクトがある場合には動作しませんIEnumerable<string>
を使用します。
JSONが無効です。 –
@PaulSwetzこれは返された応答の一部に過ぎないので、コピーしたときに有効ではなかった理由です – OstrichGlue