Home > OS >  How to use SelectToken with square brackets?
How to use SelectToken with square brackets?

Time:09-16

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"]

CodePudding user response:

use SelectToken with JSONPath.

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

dotnetfiddle

  • Related