我試圖模仿他們使用的是硬編碼的JSON什麼是生成從C#
{
"page": 1,
"total": 1,
"records": 2,
"rows": [
{"id": 1, "cell": ["1", "Super Item", "300", 0, null, false, false]},
{"id": 2, "cell": ["2", "Item 1", "100", 1, 1, false, false]},
{"id": 3, "cell": ["3", "Sub Item 1", "50", 2, 2, true, true]},
{"id": 4, "cell": ["4", "Sub Item 2", "25", 2, 2, false, false]},
{"id": 5, "cell": ["5", "Sub-sub Item 1", "25", 3, 4, true, true]},
{"id": 6, "cell": ["6", "Sub Item 3", "25", 2, 2, true, true]},
{"id": 7, "cell": ["7", "Item 2", "200", 1, 1, false, false]},
{"id": 8, "cell": ["8", "Sub Item 1", "100", 2, 7, false, false]},
{"id": 9, "cell": ["9", "Sub-sub Item 1", "50", 3, 8, true, true]},
{"id": 10, "cell": ["10", "Sub-sub Item 2", "50", 3, 8, true, true]},
{"id": 11, "cell": ["11", "Sub Item 2", "100", 2, 7, true, true]}
]
}
一個例子,但我需要從C#生成此JSON的最佳途徑。有沒有關於在C#中生成上述內容的最佳方法的建議?
'DataContractJsonSerializer'(內置)或Json.net – CodesInChaos
在我看來,答案取決於更多的信息。例如,您是否使用ASP.NET MVC,WFC或ASMX Web服務。你使用哪個.NET版本? – Oleg
@Oleg - 這是爲MVC,因爲我試圖與jqgrid Treegrid玩耍。你有任何treegrid和asp.net-mvc的例子(鑑於你是專家:)) – leora