[
{
"TotalCount":5,
"purchaseStatus":"0",
"inviteCount":0,
"status":"success",
"statusCode":"200",
"message":"success",
"user":[
{
"id":"ac789045e3f109f536e8c217e4e78fe6",
"firstname":"Srinivasan",
"lastname":"CP",
"emailid":"[email protected]",
"prof_image_path":"http:\/\/gps-dev.gpsmobitrack.com\/pickzy_dev\/upload\/img_2015-04-11-09-04-43.png",
"gcm_regid":"NULL",
"ios_device_id":"",
"longitude":"80.245255",
"latitude":"13.035394",
"relationship":"Friend",
"track_userid":"361",
"date":"2015-04-18",
"time":"13:08"
},
{
"id":"7ca84ee8cc024e3cf2f0736f89dc4ece",
"firstname":"srini",
"lastname":"cp",
"emailid":"[email protected]",
"prof_image_path":"http:\/\/gps-dev.gpsmobitrack.com\/pickzy_dev\/upload\/img_2015-04-11-08-04-41.png",
"gcm_regid":"",
"ios_device_id":"",
"longitude":"80.245255",
"latitude":"13.035394",
"relationship":"Friend",
"track_userid":"365",
"date":"2015-04-21",
"time":"19:26"
},
{
"id":"ef5b4c49b893c55ec77428b2c265510e",
"firstname":"Naveen",
"lastname":"Kumar",
"emailid":"[email protected]",
"prof_image_path":"http:\/\/gps-dev.gpsmobitrack.com\/pickzy_dev\/upload\/img_2015-04-11-08-04-51.png",
"gcm_regid":"NULL",
"ios_device_id":"fbe87350c14ccbccc1ec4ad90986faa9c1124273ed9fb7708965c83a06dd7c32",
"longitude":"80.245392",
"latitude":"13.035848",
"relationship":"Brother",
"track_userid":"367",
"date":"2015-04-10",
"time":"17:45"
},
{
"id":"e6050d8b5d378cbc791ebab1295dd301",
"firstname":"Parthiban",
"lastname":"V M",
"emailid":"[email protected]",
"prof_image_path":"http:\/\/gps-dev.gpsmobitrack.com\/pickzy_dev\/upload\/img_2015-03-28-07-03-52.png",
"gcm_regid":"NULL",
"ios_device_id":"",
"longitude":"0.000000",
"latitude":"0.000000",
"relationship":"Friend",
"track_userid":"368",
"date":"2015-04-21",
"time":"01:13"
},
{
"id":"9848d03341103f52816bf4d5a1e5467c",
"firstname":"Naveen kumar",
"lastname":"kumar",
"emailid":"[email protected]",
"prof_image_path":"http:\/\/gps-dev.gpsmobitrack.com\/pickzy_dev\/upload\/img_2015-04-11-02-04-01.png",
"gcm_regid":"NULL",
"ios_device_id":"da8ef3258c4fbc42085ab1dcb62c7b6a4bd60112bb5507284a7a8b3958808c43",
"longitude":"80.244835",
"latitude":"13.035032",
"relationship":"Other",
"track_userid":"370",
"date":"2015-04-18",
"time":"19:38"
}
]
}
]
-1
A
回答
1
使用Json2Csharp網站將您的json字符串轉換爲模型類。
您的JSON數據的模型類將是這樣的:
public class User
{
public string id { get; set; }
public string firstname { get; set; }
public string lastname { get; set; }
public string emailid { get; set; }
public string prof_image_path { get; set; }
public string gcm_regid { get; set; }
public string ios_device_id { get; set; }
public string longitude { get; set; }
public string latitude { get; set; }
public string relationship { get; set; }
public string track_userid { get; set; }
public string date { get; set; }
public string time { get; set; }
}
public class RootObject
{
public int TotalCount { get; set; }
public string purchaseStatus { get; set; }
public int inviteCount { get; set; }
public string status { get; set; }
public string statusCode { get; set; }
public string message { get; set; }
public List<User> user { get; set; }
}
此後,隨着@hans奧爾森說,使用Json.Net怒江獲得封裝庫反序列化JSON字符串轉換成模型類那些你剛來自Json2Csharp網站。
JsonConvert.DeserializeObject<RootObject>("") // your json data as string in the parameter.
1
首先創建您的數據類,您可以使用json2csharp爲您創建它們。然後使用NuGet添加參考Json.Net。
然後,你需要這樣的東西:
JsonConvert.DeserializeObject<RootObject>(YourJson)
0
一些方向爲你的研究。
3個步驟
- 獲取JSON作爲字符串
- 解析JSON的一個對象
- 綁定的對象列表
獲取JSON作爲字符串
把你的JSON成一個字符串。你需要下載它嗎?尋找這個。
將json解析爲對象
構建對象的體系結構。什麼是你的json中包含的東西?您可以使用Visual Studio來幫助我們使用像json2csharp這樣的工具。現在,你必須反序列化。 您可以使用Json.NET之類的庫爲您完成工作。我讓你看看它。
綁定的對象列表
只是可以肯定,你問一個列表框?
+0
感謝每一個 – Hasansalih
相關問題
- 1. 如何將字符串轉換爲JSON在C#中的Windows Phone
- 2. 字符串轉換爲JSON
- 3. 將CSV轉換爲Excel Windows Phone 8
- 4. 將字符串轉換爲Windows Phone 8的BackgroundImage的工具Live Tile
- 5. Windows Phone 8黑名單
- 6. Java的轉換JSON字符串爲UTF-8串
- 7. 從Windows Phone 8的URL中檢索JSON字符串
- 8. 將非JSON字符串轉換爲JSON
- 9. 字符串轉換爲JSON在JSP
- 10. JsonNode轉換JSON字符串
- 11. 將Java字符串轉換爲Json
- 12. 無法轉換爲Json字符串
- 13. 將字符串轉換爲utf-8
- 14. 將字符串轉換爲UTF-8
- 15. 將大字符串轉換爲UTF-8
- 16. 字符串轉換爲JSON使用jQuery
- 17. 轉換爲Android中的json字符串
- 18. perl:將字符串轉換爲utf-8用於json解碼
- 19. 轉換Unicode字符串爲UTF-8,然後以JSON
- 20. Coldfusion 8 JSON - 將返回字符串轉換爲查詢對象
- 21. 將字符串從Windows charset轉換爲Java中的UTF 8
- 22. 在javascript中將utf-8字符串轉換爲windows-1250
- 23. 如何將字符串轉換爲Json
- 24. 轉:將字符串數組轉換爲Json數組字符串
- 25. 字符串不能轉換爲JSON
- 26. 將Json字符串轉換爲DataTable
- 27. 將R錶轉換爲JSON字符串
- 28. 轉換JSON字符串爲Unicode
- 29. iOS字符串轉換爲JSON
- 30. 將JSON字符串轉換爲C#JsonObject
你不能複製/粘貼你的JSON並等待答案。你有什麼嘗試? – aloisdg