0

Given a json like this:

{
"post": {
        "operationId": "post-collection",
        "responses": {
          "201": {
            "description": "Post something",
            "content": {
              "application/ld+json": {
                "schema": {
                  "$ref": "./models/Mapping.jsonld.json"
                }
              },
              "application/hal+json": {
                "schema": {
                  "$ref": "./models/Mapping.jsonHal.json"
                }
              },
              "application/vnd.api+json": {
                "schema": {
                  "$ref": "./models/Mapping.vndApi.json"                },
                ...
         }
     }
}

I want the content for all, BUT application/ld+json I found a thread on how to do this based on the value: https://stackoverflow.com/a/29710922/1092632 but how would I exclude a key?

Basically what I am asking is the negative of this: $..content[application/ld+json]

Is this possible without any functions / programming? I used this for testing: https://jsonpath.com/

PrimuS
  • 2,505
  • 6
  • 33
  • 66

1 Answers1

0

https://jsonpath.com/ uses JSONPath Plus

It provides @property shorthand selector within filters

$..content[?(@property != 'application/ld+json')]

JSONPath test screenshot

Akshay G
  • 2,070
  • 1
  • 15
  • 33