最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vert.x - Usage of JsonParser to remove set of specific key from top level jsonobject - Stack Overflow

programmeradmin3浏览0评论

I have a json as buffer and I need to remove a set of keys from it. The json is pretty big and I do not want to cast it into JsonObject. Let's say I want to remove key a, b, c, d and e only from top level json (depth=0) and not from depth 1 onwards.

It would be great if depth can be taken as an argument as well to support deletion from child as well.

So if I have a json as this:

{
  "a": "1",
  "b": {
    "b1": 2
  },
  "c": [
    "3",
    {
      "c1": 4
    },
    [
      9,
      10
    ]
  ],
  "d": false,
  "e": 1.0,
  "f": {
    "a": 1
  },
  "g": [
    {
      "b": 2
    }
  ],
  "h": {
    "c": [
      "3",
      {
        "c1": 4
      },
      [
        9,
        10
      ]
    ]
  },
  "j": {
    "d": true,
    "e": 1.0
  },
  "k": true
}

I want to use vert.x JsonParser to remove a, b, c, d and e and get this as the final buffer

{
  "f": {
    "a": 1
  },
  "g": [
    {
      "b": 2
    }
  ],
  "h": {
    "c": [
      "3",
      {
        "c1": 4
      },
      [
        9,
        10
      ]
    ]
  },
  "j": {
    "d": true,
    "e": 1.0
  },
  "k": true
}

Can you please help me with this. I am on vert.x 4.5.13

Preferred is vert.x solution but I am also ok with Jakarta JsonParser library as well

发布评论

评论列表(0)

  1. 暂无评论