提供された情報(検索サービス)に応じて、文字列要素または文字列要素のリストのいずれかを含む要素を返すRESTサービスを扱っています。たとえば、画像が0個以上あるアイテムを検索する場合があります-url-stringsとして保存されます。Mymodel
には、私の例を処理するための次のプロパティが含まれています。
private List<string> _Images = new List<string>();
[DataMember(Name="images", IsRequired=false)]
public List<string> Images
{
get
{
return _Images;
}
set
{
_Images = value;
onPropertyChanged("Images");
}
}
JSON
いくつかの画像のサンプル:
{
"id": 24955,
"title": "Conan the Barbarian",
"duration": 105,
"hd": false,
"trailer": "800/BM_6305_800_tr.wmv",
"images": [
"http://website.com/images/conanthebar_1.jpg",
"http://website.com/images/conanthebar_2.jpg",
"http://website.com/images/conanthebar_3.jpg",
"http://website.com/images/conanthebar_4.jpg",
"http://website.com/images/conanthebar_5.jpg",
"http://website.com/images/conanthebar_6.jpg"
]
}
1つの画像のサンプルJSON
:
{
"id": 24955,
"title": "Conan the Barbarian",
"duration": 105,
"hd": false,
"trailer": "800/BM_6305_800_tr.wmv",
"images": "http://website.com/images/conanthebar_6.jpg"
}
さて、私の質問は、私が使用しているとき、DataContractJsonSerializer
これはどのように処理されるのでしょうか?着信jsonの画像文字列が(配列/文字列のリストと比較して)単一の文字列である場合、メンバーが1つしかない文字列のリストに変換されますか?
最後に、これが当てはまらない場合(私の理論は誤りです)、そのような状況はどのように処理できますか?