如何从java中的json httpresponse中删除某些字段?

时间:2017-06-01 19:17:31

标签: java json elasticsearch

我正在使用来自Spring启动应用程序的Java rest客户端与ES交互,我的响应是JSON对象。

见下面的示例。

删除某些不需要的字段最有效的方法是什么?

例如:删除“take”,“success”。“”_ source.accountname“

由于这是一个嵌套的json对象,并且很有可能获得更大的响应,我试图找出最有效的方法。我担心循环遍历每个嵌套对象会咀嚼时间

{
  "took" : 63,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : null,
    "hits" : [ {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "0",
      "sort": [0],
      "_score" : null,
      "_source" : {"account_number":0,"balance":16623,"firstname":"Bradshaw","lastname":"Mckenzie","age":29,"gender":"F","address":"244 Columbus Place","employer":"Euron","email":"bradshawmckenzie@euron.com","city":"Hobucken","state":"CO"}
    }, {
      "_index" : "bank",
      "_type" : "account",
      "_id" : "1",
      "sort": [1],
      "_score" : null,
      "_source" : {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
    }, ...
    ]
  }
}

0 个答案:

没有答案