我正在從ElasticSearch獲得響應(yīng),從該響應(yīng)中我想形成另一個(gè)字段有限的JSON(例如自定義JSONObject)。請(qǐng)找到通過彈性搜索得到的響應(yīng)。{ "took":93, "timed_out":false, "_shards":{ "total":5, "successful":5, "skipped":0, "failed":0 }, "hits":{ "total":1, "max_score":1.0, "hits":[ { "_index":"attachment", "_type":"doc", "_id":"87740", "_score":1.0, "_source":{ "app_language":"ES", "filetype":"PB", "attachment":{ "date":"2006-05-03T15:17:53Z", "content_type":"application/pdf", "author":"JJamesN", "language":"en", "title":"Microsoft Word - te7000pb.doc", "content":"European Electronic Controls Catalog ", "content_length":12267 }, "ext":"pdf", "fileContent":"JVBERi0xLjQNJeLjz9MNCjQ3ID" } } ] }}請(qǐng)找到我的Java代碼,該Java代碼試圖操縱響應(yīng)JSON以創(chuàng)建具有有限字段的單獨(dú)JSON。JSONObject jsonObject = new JSONObject(responseBody);JSONObject hits = jsonObject.getJSONObject("hits");JSONArray hitsArray=hits.getJSONArray("hits");System.out.println("Hits---->"+hitsArray.toString());從響應(yīng)JSON,我只想使用以下結(jié)構(gòu)和字段創(chuàng)建一個(gè)新的JSON。 { "app_language":"ES", "filetype":"PB", "attachment.content" : "European Electronic Controls Catalog ", "ext":"pdf", }
根據(jù)彈性搜索的JSON響應(yīng)形成自定義JSON對(duì)象
慕的地6264312
2021-04-16 18:16:32