1

Hi I have a JSON Object:

{      
    "idContainer": 
    [
        "213=135864",
        "312=35947"
    ]
}

Now I want to access the string 135864 that is after 213= (213 is a kind of key inside of the array value, I get the data formatted like this)

  • I can not say for certain that it is the first element in the Array, just that it begins with the "key" 213=
  • The String result of my Xpath expression should be optimally just 135864 and no single or double quotes

1.) I am trying to find a filter expression like this idContainer[?('213=*')] which returns me this element "213=135864"

2.) More convenient would be if I could filter the result even more and just return 135864 but I don't know if this is possible with JSON XPath Syntax

Thanks for help :)

If necessary I could also use Java expressions, but my favorite Solution would be pure JsonPath

1
  • For me this works: idContainer[?(@.213 contains '135864')] Commented Mar 17, 2023 at 14:09

1 Answer 1

1

If you're using Jayway JSONPath, and if you're working in JAVA you probably are, you can use regular expressions in a filter condition, viz.

$.idContainer[?(@ =~ /213=.*/)]

That produces

[
   "213=135864"
]

But there's no way using Jayway to produce

[
    135864
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.