Skip to content

Return as object with key and value of match. #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dionsnoeijen opened this issue Apr 26, 2021 · 1 comment
Open

Return as object with key and value of match. #153

dionsnoeijen opened this issue Apr 26, 2021 · 1 comment
Labels

Comments

@dionsnoeijen
Copy link

dionsnoeijen commented Apr 26, 2021

With this json:

{
  "firstName": "John",
  "lastName" : "doe",
  "age"      : 26,
  "address"  : {
    "streetAddress": "naist street",
    "city"         : "Nara",
    "postalCode"   : "630-0192"
  },
  "phoneNumbers": [
    {
      "type"  : "iPhone",
      "number": "0123-4567-8888",
      "other" : "value"
    },
    {
      "type"  : "home",
      "number": "0123-4567-8910",
      "other" : "value"
    }
  ]
}

A query like this: $.phoneNumbers.[type,number] returns:

[
  "iPhone",
  "0123-4567-8888",
  "home",
  "0123-4567-8910"
]

It would be very helpful if there is an option to make the result as this:

[
    {"type": "IPhone", "number": "0123-4567-8888"},
    {"type": "home", "number": "0123-4567-8910"}
]
@callumgare
Copy link

I would also love this! There is already a syntax that is used by a couple of other parses so I think it makes most sense to use that syntax: https://cburgmer.github.io/json-path-comparison/results/parens_notation.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants