私は次のjsonをかき混ぜています
{
"api_version" : 2 ,
"lang" : "en_US",
"hotels" :
[
{
"hotel_id" : 258705 ,
"desc" : "The Hotel Commonwealth stands above the Kenmore Square \"T\" subway station in Boston, Mass. Fenway Park is located two blocks away, while the shops along Newbury Street are three blocks from the hotel.",
"amenities" : ["RESTAURANT","NON_SMOKING"],
"room_types" :
{
"Fenway Room" :
{
"url" : "http://www.partnersite.com/hotel_commonwealth/fenway_room",
"desc" : "One king bed with pillowtop mattress, Frette Italian linens, down bedding, multiple pillows. View of Fenway Park."
},
"Commonwealth Room" :
{
"url" : "http://www.partnersite.com/hotel_commonwealth/commonwealth_room",
"desc" : "One king bed with pillowtop mattress, Frette Italian linens, down bedding, multiple pillows. View of Commonwealth Avenue."
}
}
}
]
}
そして、次の poco クラスを作成しました。NewtonSoft を使用して上記の文字列を逆シリアル化できます。
internal class FenwayRoom
{
}
internal class CommonwealthRoom
{
}
internal class RoomTypes
{
[JsonProperty("Fenway Room")]
public FenwayRoom FenwayRoom { get; set; }
[JsonProperty("Commonwealth Room")]
public CommonwealthRoom CommonwealthRoom { get; set; }
}
internal class Hotel
{
}
}
問題は、部屋の種類ごとに隔壁クラスを作成する必要があることです。これに対するより良いアプローチはありますか?