1

How can I get the value or make a SelectToken, if the Name of the JToken includes square brackets? tmpJToken.Value(Of String)("3/32[v]") or tmpJToken.SelectToken("3/32[v]")

Do I have to escape the square brackets?

The JSON looks like:

["BeginOfEnumerable",
  [
    {
        "Classification": [
            "/",
            "/Document/"
            
        ],
        "FieldValues": {
            "/0": "8854723",                
            "/3/32[v]": "1856929"                
        },
        "Key": "urn:key:Document:1856929"
    }
],
"EndOfEnumerable"]
Akshay G
  • 2,070
  • 1
  • 15
  • 33
Mec-Eng
  • 199
  • 10

1 Answers1

0

use SelectToken with JSONPath.

Dim result = tmpJToken.SelectToken("$..FieldValues.['/3/32[v]']")

dotnetfiddle

Akshay G
  • 2,070
  • 1
  • 15
  • 33
  • Unfortunately this does not work for the case `["FieldValues", {"3/32[v]": "1856929"}]` Is the syntax different for VB.Net? – Mec-Eng Sep 13 '21 at 13:39
  • Please excuse the confusion about the simplified JSON. Now I have pasted the complete, original JSON above. – Mec-Eng Sep 14 '21 at 05:50
  • @Mec-Eng I have updated the answer based on the original JSON – Akshay G Sep 14 '21 at 06:28