仅保留给定 json

问题描述

我有一个 JSON 和一个 jsonPath 字符串列表。我想从 JSON 中删除所有内容,只保留我拥有的 jsonPaths 列表。我正在使用 Jayway's JsonPath

说我的 jsonPaths 是:

  1. $.c
  2. $.b[?(@.name=='ironman')]

我的 JSON 是

{
    "a":"1","b":[
        {
            "name": "ironman"
        },{
            "name": "thor"
        }
    ],"c": {
        "d":{
            "e": "nested"
        }
    }
}

我希望生成的 JSON 是

 "b":[
        {
            "name": "ironman"
        }
    ],"c": {
        "d":{
            "e": "nested"
        }
    }

有没有什么简单的方法可以做到这一点?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)