NajLinus NajLinus - 6 months ago 92
PHP Question

How to get value of JSON array or object in VB.net?

I have JSON file having following data. I just want to get the data of "naming" and "unit". Please assist me how to do this in VB.net?

[
{
"customerId": "999",
"deviceId": "XXX999",
"searchDeviceId": "D_XXX999",
"utc": "2016-04-28T03:37:00.000Z",
"lat": 22.5691,
"lng": 120.3058,
"sensors": [
{
"naming": "ABC123",
"factor": null,
"unit": "k",
"period": null
},
{
"naming": "XYZ123",
"factor": null,
"unit": "c",
"period": null
},
.
.
.
.
.
]
}
]

Answer

For C# :

JObject jResults = JObject.Parse("JsonString");
String naming = jResults["sensors"]["naming "];
String unit = jResults["sensors"]["unit "];

For VB:

Dim jResults As JObject = JObject.Parse("JsonString")
Dim naming As [String] = jResults("sensors")("naming ")
Dim unit As [String] = jResults("sensors")("unit ")

You can achieve like this.