0

I need to deserialize this, which is encoded in JSON and I can not, I need it, anyone can help me?

[{"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

WilQu
  • 7,131
  • 6
  • 30
  • 38

2 Answers2

1

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.

The documentation provides an example of how to deserialise an object.

Community
  • 1
  • 1
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
1

Expanding on Mr Shoubs' answer:

1) Download the Json.Net DLL per Mr Shoubs' answer.

2) Add a reference to this DLL in your Visual Studio Project.

enter image description here

3) Create a VB Reservation class that you want to end up with:

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.

4) Declare an object of type Reservation and populate it with the JSON string you have - using the DeserializeObject method:

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

obj should now contain the data you want.

mr_plum
  • 2,448
  • 1
  • 18
  • 31