Issues with JSONPath Plus syntax in Insomnia - Unable to Retrieve Multiple values at different levels

63 Views Asked by At

Here's a simplified version of my JSON structure:

{
  "data": {
    "jobs": [
      {
        "jobId": "85c9f596-85f5-4ffa-8b94-2cde23162ddf",
        "jobNotes": {
          "note1": "Some note 1",
          "note2": "Some note 2"
        }
      },
      // ... other job objects
    ]
  }
}

I want to retrieve something like this in insomnia using the jsonPath-plus syntax to show some thing like the following:

{
      "jobId": "job1",
      "jobNotes": [
             {
               "stuff":"blah",
               "stuff2": "3"
             }
          ],
}

I want to see the jobId and associated jobNotes but only when jobNotes exist

I tried

data.jobs[*].['jobId', 'jobNotes'][?(@.jobNotes != null)]

But got [] so I presume my syntax isn't quite right?

Using insomnia version:

Version: Insomnia 2023.5.8
Build date: 9/7/2023
OS: Darwin arm64 22.6.0
Electron: 25.2.0
Node: 18.15.0
Node ABI: 116
V8: 11.4.183.23-electron.0
Architecture: arm64
0

There are 0 best solutions below