在 VB.net 中将 JSON 字符串反序列化为动态列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17870433/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 14:24:41  来源:igfitidea点击:

Deserialize JSON string into Dynamic List in VB.net

jsonvb.netasp.net-web-apideserialization

提问by Matt

I've got the following JSON string which I have retrieved from a webapi:

我有从 webapi 检索到的以下 JSON 字符串:

[{"WorkOrderID":2,"WorkOrderNumber":1},{"WorkOrderID":3,"WorkOrderNumber":3}]

Now I want to know if there is a way I can deserialize this into a list of type dynamic in VB.NET?

现在我想知道是否有办法将其反序列化为 VB.NET 中的动态类型列表?

The JSON string could be coming in any format (therefore I cannot deserialize it to a standard class type) and I just need to deserialize it into a list so it can be used a datasource for a grid.

JSON 字符串可以采用任何格式(因此我无法将其反序列化为标准类类型),我只需要将其反序列化为一个列表,以便将其用作网格的数据源。

Is this achievable.

这能不能实现。

采纳答案by Jargs

For VB.Net:

对于 VB.Net:

Dim x As Object = JsonConvert.DeserializeObject(of Object)(json)