不一一反序列化JSON [英] deserialize JSON without one by one

查看:121
本文介绍了不一一反序列化JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个JSON:

{"JOE":"0.90000000","BILL":"3.30000000","MONROE":"1.20000000"}

{"JOE":"0.90000000","BILL":"3.30000000","MONROE":"1.20000000"}

当我在VB.NET中进行特殊粘贴时,此操作已创建:

when i do a paste especial in VB.NET, this was created:

Public Class Rootobject
    Public Property JOE As String
    Public Property BILL As String
    Public Property MONROE As String
End class

有3个元素,可以处理,但有200个,没有. 我需要一种声明JSON数据的方式,以便通过

With 3 elements, it can be handled, but with 200, no. i need the way to declare the JSON data in order to access with a

for each in 
next

,并查看每个带有索引的名称和值对数据的迭代.

and look in any iteraction for each name and value couple of data with an index.

JSON的正确定义是什么,反序列化并获取所有数据的代码是什么?

what is the right definition for JSON and what is the code for deserialize and get all the data?

预先感谢

推荐答案

尝试一下

var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

更新:

刚刚意识到您想要在VB.NET中

Just realized that you want it in VB.NET

Dim j1 As String = "{ ""JOE"":""0.90000000"",""JOE"":""3.30000000"",""MONROE"":""1.20000000""}"
Dim dict = JsonConvert.DeserializeObject(Of Dictionary(Of String, String))(j1)
For Each kvp In dict
    Console.WriteLine(kvp.Key & " - " + kvp.Value)
Next

https://dotnetfiddle.net/YrLuyX

工作示例

PS:JSON.NET也可以处理重复项.

PS: JSON.NET handles duplicate as well.

这篇关于不一一反序列化JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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