java - Trouble parsing JSONArray within JSONObject -


for reason whole array read when try select 1 segment doesn't let me see past past segment in array array length equals 1, got squashed 1 element. code:

https://github.com/yehudaclinton/mytest/blob/master/testhttp.java

            try {                 object obj = parser.parse(result);                 jsonobject jsonobject = (jsonobject) obj;                 jsonarray items = (jsonarray) jsonobject.get("items");                 log.d(tag, "items length: " + items.size());//for reason not more 1                 string name = "";                 //the following supposed return title of book                 (int = 0; < items.size(); i++) {                     jsonobject item = (jsonobject) items.get(i);//if 'i' equals more 1 program crashes                     if(item.get("title")!=null) {//only title                         jsonobject thetitle = (jsonobject) item.get("title");                         name = (string) thetitle.get("title");                     }                 } 

result = name;

i called url you've got in code https://www.googleapis.com/books/v1/volumes?q=ltrump&maxresults=1 , 'items' array of length 1 anyway. try removing &maxresults=1 url?

so use url instead https://www.googleapis.com/books/v1/volumes?q=ltrump


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -