If I have a datatable in the following structure.
HostelName FloorName FlatName Occupied Vacant
Building One Floor AA 2 2
Building One Floor AB 0 4
Building One Floor AC 0 4
Building One Floor AD 0 4
Building One Floor AE 0 4
Building One Floor BF 0 4
Building One Floor BG 0 4
Building One Floor BH 0 4
Building One Floor BI 0 4
Building One Floor BJ 0 4
I would like to serialize it as a JSON object, where the columns HostelName, FloorName and FlatName are nodes in the JSON object, for example:
{ "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" } } } };
Please help me solve the problem.
source share