Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.47k stars 1.95k forks source link

Filtering all the keys not working #3258

Open dingo-d opened 3 years ago

dingo-d commented 3 years ago

Describe the bug I'm trying to filter out all the keys from the JSON response of WordPress API. When going to https://jsonpath.com/ and trying

$.routes.*~

I get the keys of all routes. When I type this in the Insomnia I get an empty array.

To Reproduce JSON example

{
  "name": "WordPress",
  "description": "Just another WordPress site",
  "url": "https:\/\/mysite.test",
  "home": "https:\/\/mysite.test",
  "gmt_offset": "0",
  "timezone_string": "",
  "namespaces": [
    "oembed\/1.0",
    "menus\/v1",
    "acf\/v3",
    "wc-bookings\/v1",
    "wc\/store",
    "wc-analytics",
    "wc-admin",
    "wc\/v1",
    "wc\/v2",
    "wc\/v3",
    "wccom-site\/v1",
    "wp\/v2",
    "wp-site-health\/v1"
  ],
  "authentication": {
    "application-passwords": {
      "endpoints": {
        "authorization": "https:\/\/mysite.test\/wp-admin\/authorize-application.php"
      }
    }
  },
  "routes": {
    "\/": {...},
    "/batch/v1": {...},
    "/oembed/1.0": {...},
    "/oembed/1.0/embed": {...},
    "/oembed/1.0/proxy": {...}
  }
}

Expected behavior I expect to see something like

[
  "/",
  "/batch/v1",
  "/oembed/1.0",
  "/oembed/1.0/embed",
  "/oembed/1.0/proxy"
]

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

dimitropoulos commented 3 years ago

@dingo-d do you happen to know how this query would be written with jq syntax?

dingo-d commented 3 years ago

I managed to get the same result with

curl ... | jq -r '.routes | keys'
dimitropoulos commented 3 years ago

ok, thanks. just curious, would you prefer it if insomnia used/allowed jq instead of (or perhaps as an option in addition to) jsonpath?

dingo-d commented 3 years ago

Sure, whatever works 😄

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.