Search code examples
jsonjsonpath

How can I get the first result from a JSON using JSONPATH. Confused


I am unsure of what to do. I've tried "$..name" which gives me all the names in the json, then I tried "$..name[0]" which should give me the first result, but didn't. What should I do? I tried this on json path tester.

JSON I'm using: https://pastebin.com/zuarCkjK

Solution

  • Try using this

    $..[0].name
    

    If it works right, the output should be

    [
      "test1"
    ]