如果我有以下結構的DataTable。轉換數據表到JSON只值
HostelName FloorName FlatName Occupied Vacant Building One Floor A A 2 2 Building One Floor A B 0 4 Building One Floor A C 0 4 Building One Floor A D 0 4 Building One Floor A E 0 4 Building One Floor B F 0 4 Building One Floor B G 0 4 Building One Floor B H 0 4 Building One Floor B I 0 4 Building One Floor B J 0 4
我想序列化的JSON對象,其中HostelName,FloorName & FlatName列是JSON對象,如節點:
{
"Building One": {
"Floor A": {
"A": {
"Occupied": "2",
"Vacant": "2"
},
"B": {
"Occupied": "0",
"Vacant": "4"
},
"C": {
"Occupied": "0",
"Vacant": "4"
},
"D": {
"Occupied": "0",
"Vacant": "4"
},
"E": {
"Occupied": "0",
"Vacant": "4"
}
},
"Floor B": {
"F": {
"Occupied": "0",
"Vacant": "4"
},
"G": {
"Occupied": "0",
"Vacant": "4"
},
"H": {
"Occupied": "0",
"Vacant": "4"
},
"D": {
"Occupied": "0",
"Vacant": "4"
},
"I": {
"Occupied": "0",
"Vacant": "4"
}
}
}
};
請幫我解決這個問題。
嘗試使用'StringBuilder'生成JSON。 –
你能告訴我們你到目前爲止做了什麼? –
您是否設法至少查詢表中的數據?你有什麼麻煩? – greenfeet