2012-01-18 129 views
6

我有一個來自Web服務的JSON響應,我需要將其轉換爲對象,然後轉換爲數組。我的回覆類似於下面的那個:將JSON字符串轉換爲JSON對象

{"status":{"error":"NO","code":"200","description":"none","message":"Request ok"},"geolocation":{"lat":"38.89515","lng":"-77.0310"},"stations":[{"country":"United States","regPrice":"0.00","midPrice":"0.00","prePrice":"0.00","streetAddress":"1401, I St NW","ID":"1900","lat":"38.901440","lng":"-77.032127","stationName":"Shell","logo":"http:\/\/www.nyneaxis.com\/logo\/stations\/noLogo.png","state":"District of Columbia","city":"Washington D.C.","regDate":null,"midDate":null,"preDate":null,"distance":"0.7"},{"country":"United States","regPrice":"0.00","midPrice":"0.00","prePrice":"0.00","streetAddress":"2116-2150, M St NW","ID":"13029","lat":"38.905201","lng":"-77.048103","stationName":"Exxon","logo":"http:\/\/www.nyneaxis.com\/logo\/stations\/noLogo.png","state":"District of Columbia","city":"Washington D.C.","regDate":null,"midDate":null,"preDate":null,"distance":"1.9"}]} 

我這樣做的是VB.NET內控制檯現在。基本上我試圖創建一個簡單的方法來測試我的API調用並輸出信息。我試圖完成的是不得不循環遍歷JSON數組並列出工作站。我從來沒有在VB.NET中做過這件事,並希望得到一些幫助。我一直在閱讀有關反序列化的內容,但並不瞭解它。

+0

看到這個問題http://stackoverflow.com/questions/1474377/json-library-for-c-sharp – MarkJ 2012-01-18 08:13:43

回答

0

有一個很好的庫.NET稱爲Json.NET http://json.codeplex.com/

有一堆的例子,主要是C#,雖然這對做這種東西是有用的。

5

您可以使用Json.NET

Dim ThisToken as Token = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Token)(JSonString) 
相關問題