简体   繁体   English

json反序列化vb.net

[英]json deserialization vb.net

I need to deserialize this, which is encoded in JSON and I can not, I need it, anyone can help me? 我需要反序列化,它是用JSON编码的,我不能,我不需要,任何人都可以帮助我吗?

[{"idReservation":2560,
"startDate":"30/09/2013 09:00",
"endDate":"30/09/2013 09:10",
"timeOut":"24/09/2013 16:02:23",
"idResource":1477,
"resourceDescription":"Profesional",
"players":
[{"idPlayer":283,
"idCustomer":2,
"name":"Ignacio",
"image":"/public/images/interface/customer/user.png",
"total":0}],
"anulable":true,
"name":"Ignacio",
"price":0,
"status":"Reservada",
"parententityname":"",
"idparententity":"",
"unixTime":1380524400},]

greetings and thank you very much 问候,非常感谢你

Expanding on Mr Shoubs' answer: 扩大肖布斯先生的回答:

1) Download the Json.Net DLL per Mr Shoubs' answer. 1)根据Shoubs先生的回答下载Json.Net DLL。

2) Add a reference to this DLL in your Visual Studio Project. 2)在Visual Studio项目中添加对此DLL 的引用

在此处输入图片说明

3) Create a VB Reservation class that you want to end up with: 3)创建一个您想要结束的VB Reservation类:

Public Class Reservation
    Public Property idReservation() as Integer
    Public Property startDate() as Date
    ...
End Class

Make the spelling and casing exactly as they are in the JSON object to keep things simple. 使其拼写和大小写与JSON对象中的内容完全相同,以使事情简单。

4) Declare an object of type Reservation and populate it with the JSON string you have - using the DeserializeObject method: 4)使用DeserializeObject方法声明一个类型为Reservation的对象,并使用您拥有的JSON字符串填充该对象:

Dim obj As Reservation
obj = JsonConvert.DeserializeObject(Of Reservation)(yourJsonString)

obj should now contain the data you want. obj现在应包含所需的数据。

As @YuriyGalanter suggests Json.NET will do the job, it has great performance and avoids the problem you get when trying to serialise a javascript datetime object to .net datetime object. 正如@YuriyGalanter建议Json.NET会做的那样,它具有出色的性能,并且避免了在尝试将javascript datetime对象序列化为.net datetime对象时遇到的问题

The documentation provides an example of how to deserialise an object. 文档提供如何反序列化对象的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM