0

Given JSON like:

[
    {
        "Serial no": 994,
    },
    {
        "Serial no": 456,
    }
]

I know this query will give me an array of all Serial no values, in the order they are in the JSON: $..['Serial no']

I'm not sure exactly what sorting capabilities JSONPath has but I think you can use / and \ to sort - but how are they used to modify my query string in this case? I am only interested doing this in pure JSONPath, not JS or post-query sorting - that's easy, I just want to know if I can avoid it.

This is a source I found suggesting sorting is supported but it might be product-specific?

I'm using http://www.jsonquerytool.com/ to test this

Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • That's not JSON (JSON does not allow dangling commas). And AFAIK, basic JSONPath has no sorting capabilities, though some libraries (like `jsonpath` for Python) do add those extensions. – Amadan Aug 16 '19 at 11:15
  • Thanks, fixed that dangling comma. It's from a huge real-world dataset I had to sanitise. – Mr. Boy Aug 16 '19 at 12:18

0 Answers0