get value from a JSONObject

时间:2015-07-28 16:08:16

标签: java parsing jsonobject

I have a JSONObject.

{
  "_shards":{
      "total":251,
      "failed":0,
      "successful":251
   },
   "hits":{
      "hits":[

      ],
      "total":7775532,
      "max_score":0
   },
   "took":517,
   "timed_out":false,
   "facets":{
      "terms":{
         "total":2287,
         "other":0,
         "terms":[
            {
               "count":2268,
               "term":"contact"
            },
            {
               "count":19,
               "term":""
            }
         ],
         "_type":"terms",
         "missing":424
      }
   }
}

I want to get the value of hits.total which here is 7775532. How can I get that ? Is there some function that can help ? I am using Java

1 个答案:

答案 0 :(得分:0)

jsonObject.getJSONObject("hits").get("total")