将JSON字符串转换为JSON对象 [英] Convert JSON String to JSON Object

查看:135
本文介绍了将JSON字符串转换为JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Web服务收到JSON响应,我需要将其转换为对象,然后转换为数组.我的回应与以下回应类似:

I have a JSON response from a web service that I need to be converted to an object then to an array. My response is similar to the one 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 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中做到这一点,并且希望获得一些帮助.我一直在阅读有关反序列化的信息,但不了解.

I am doing this is VB.NET within a console for now. Basically I am trying to create a simple way to test my API calls and output the information. What I am trying to accomplish is having to loop through the JSON array and list the stations. I have never done this in VB.NET before and would like some help. I have been reading about deserialization but do not understand it.

推荐答案

.NET有一个名为Json.NET的良好库,对于执行此类操作很有用

There's a good library for .NET called Json.NET that's useful for doing this kind of stuff http://json.codeplex.com/

有很多例子,不过大多数都是C#.

there are a bunch of examples, mostly C# though.

这篇关于将JSON字符串转换为JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆