0

I have a data in this format.

{"responseData": {"results":[{"GsearchResultClass":"GwebSearch",.......}],"cursor":{"resultCount":"16,900,000","pages":[........

I have put the full text into this first.

JSONObject fullResult = new JSONObject(text);//text represents my data.

JSONObject responseData1 = fullResult.JSONObject("responseData"); 

here I keep getting this "error: method getJSONObject in class JSONObject cannot be applied to given types;".

I need to extract just the value of resultCount. I keep getting stucked here.

1 Answer 1

1

the method is called getJSONObject( String ) i think

Sign up to request clarification or add additional context in comments.

6 Comments

Can I directly access the "resultCount":"16,900,000"? I just need the value of 16,900,000?
@user2711681 No, it is nested in another JSON object. You need to get that JSON object first (and whatever else is in between).
Ok I got it JSONObject fullResult = new JSONObject(text); JSONObject responseData1 = fullResult.getJSONObject("responseData"); JSONObject cursor1= responseData1.getJSONObject("cursor"); I guess this lead me till cursor am I right ?
@user2711681 Try it and see.
Yes it works I got it thank you System.out.println("\nJSON : "+cursor1.getString("resultCount")); but what is best mechanism to covert this string into big integer?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.