Convert JSON string to JSON object

I have a JSON response from a web service that I need to convert to an object and then to an array. My answer is similar to below:

{"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 DC","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 DC","regDate":null,"midDate":null,"preDate":null,"distance":"1.9"}]} 

Now I am doing this VB.NET in the console. Basically, I am trying to create an easy way to test my API calls and display information. What I'm trying to accomplish is to go through a JSON array and list the stations. I have never done this in VB.NET before and would like to help. I read about deserialization, but don't understand.

+6
source share
4 answers

There is a good .NET library called Json.NET that is useful for creating this kind of material http://json.codeplex.com/

there are a bunch of examples, mostly C #.

0
source

You can use Json.NET

 Dim ThisToken as Token = Newtonsoft.Json.JsonConvert.DeserializeObject(Of Token)(JSonString) 
+5
source

http://msdn.microsoft.com/en-us/library/bb412179.aspx contains detailed "How to" on this topic

+1
source

If you are using .NET 4.0+, you can use JavaScriptSerializer Deserialization Method: Deserialize JSON with JavaScriptSerializer

Note. Keep in mind that for deserialization you must have a .NET class with all the properties of a JSON object.

0
source

Source: https://habr.com/ru/post/906255/


All Articles