-1

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

vcsjones
  • 138,677
  • 31
  • 291
  • 286
Aishwarya Garg
  • 39
  • 2
  • 2
  • 7
  • possible duplicate of [Convert a JSON string to object in Java?](http://stackoverflow.com/questions/1395551/convert-a-json-string-to-object-in-java) – Quentin Jul 28 '15 at 16:11
  • Java also has a default library you can use, which is pointed out in [this](http://stackoverflow.com/questions/2591098/how-to-parse-json-in-java) answer – Gnarlywhale Jul 28 '15 at 16:24

1 Answers1

0
jsonObject.getJSONObject("hits").get("total")
cahen
  • 15,807
  • 13
  • 47
  • 78