Archived Forum Post

Index of archived forum posts

Question:

VB.NET Json Path

Feb 20 '17 at 09:31

I have created the following json :

{
  "emails": [
    {
      "someval": 0,
      "otherval": 2
    }
  ]
}

and I try to accessit like so :

priceObj.IntOf(".emails[0].otherval")
 priceObj.IntOf(".emails.otherval")

The output is 0 (invalid), tried my best to solve this but could not.

Can you please tell me how can I acces the value of "otherval" using path ? Thanks in advance.


Answer

How about something like this:

Dim employees As ChilkatJsonArray

Set emails = json.ArrayOf("emails")

Dim email As ChilkatJsonObject
Set email = emails.ObjectAt(0)

'  IntOf
Debug.Print "otherval: " & email.IntOf("otherval")

Answer

The path is this:

priceObj.IntOf("emails[0].otherval")