简体   繁体   中英

JSONPath exclude key in paths

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/

https://jsonpath.com/ uses JSONPath Plus

It provides @property shorthand selector within filters

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

JSONPath 测试截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM