Json.NET を使用して、次の JSON を逆シリアル化しています。
[
{
"id": 1234,
"name": "Example",
"coords": "[12:34]",
"relationship": "ownCity"
},
{
"id": 53,
"name": "Another example",
"coords": "[98:76]",
"relationship": "ownCity"
}
]
リストに解析しようとしています。
List<City> cities = JsonConvert.DeserializeObject<List<City>>(json);
City クラスの定義:
public class City
{
int id { get; set; }
string name { get; set; }
string coords { get; set; }
string relationship { get; set; }
}
結果は 2 つの City オブジェクトのリストになりますが、それらのプロパティはすべて null (id は 0) です。
誰かが私が間違っていることを教えてくれますか? 前もって感謝します。