0
我有傳入JSON格式是這樣的:需要JSON轉換爲數據表
{
"users": [
{
"radio_id": "123582",
"callsign": "ABCD",
"name": "First Last",
"city": "Dortmund",
"state": "Nordrhein-Westfalen",
"country": "Germany",
"home_rptr": "W2VL",
"remarks": "None"
},
{
"radio_id": "789456",
"callsign": "EFG",
"name": "Name Here",
"city": "Dortmund",
"state": "Nordrhein-Westfalen",
"country": "Germany",
"home_rptr": "W2VL",
"remarks": "None"
}
]
}
它是從一個Web請求,我趕上到一個名爲dataReceived串到來。然後我使用這行代碼轉換爲數據表。讀取數據表時 意外JSON令牌:
DataTable dtData = (DataTable)JsonConvert.DeserializeObject(dataReceived, (typeof(DataTable)));
我得到的錯誤。預期StartArray,得到StartObject。路徑'',第1行,位置1.
我懷疑我的問題是數據在數組中,但我不知道如何解決這個問題。我的目標是在json中爲每行的「用戶」對象設置一個表格。
任何人都可以把我推向正確的方向嗎?
你可以嘗試使用反序列化http://stackoverflow.com/questions/25782765/newtonsoft-json-jsonconvert-to-datatable – Krishna