java - JSONException: Object has been collected Cannot evaluate JSONObject.toString() -


while there many post topic android unable find explanation situation in happening mid-way through json parsing.

the results get shown below , passed parsepopularmoviejson(string json) method below.

{    page:1,    results:[       {          poster_path:"/fyzpm9gmpblic893fnjowcwe24h.jpg",          adult:false,          overview:"thirtyyears after defeating galactic empire, han solo , alliesface new threat evil kylo ren , army ofstormtroopers.",          release_date:"2015-12-18",          genre_ids:[             28,             12,             878,             14          ],          id:140607,          original_title:"star wars: force awakens",          original_language:"en",          title:"star wars: force awakens",          backdrop_path:"/njv65rtipnstozfluf85jl0bcqe.jpg",          popularity:57.865219,          vote_count:2529,          video:false,          vote_average:7.84       },       {          poster_path:"/msvpkowbyftlro9bjfegquw5dxe.jpg",          adult:false,          overview:"a cryptic message bond’s past sends him on trail touncover sinister organization. while m battles political forces tokeep secret service alive, bond peels layers of deceit toreveal terrible truth behind spectre.",          release_date:"2015-10-26",          genre_ids:[             28,             12,             80          ],          id:206647,          original_title:"spectre",          original_language:"en",          title:"spectre",          backdrop_path:"/wvtylkkpkrljjfugxn7ullnjtuj.jpg",          popularity:51.83321,          vote_count:1697,          video:false,          vote_average:6.32       },       {          poster_path:"/oxuwec5i3wyyfnl1ycu8ppxxpvs.jpg",          adult:false,          overview:"in the1820s, frontiersman, hugh glass, sets out on path of vengeanceagainst left him dead after bear mauling.",          release_date:"2015-12-25",          genre_ids:[             37,             18,             12,             53          ],          id:281957,          original_title:"the revenant",          original_language:"en",          title:"therevenant",          backdrop_path:"/us1skjvviragffngkdwe7ohtm8b.jpg",          popularity:46.269385,          vote_count:750,          video:false,          vote_average:7.32       },       {          poster_path:"/5aghaihyuqbqlhwvwyqmcnj40y2.jpg",          adult:false,          overview:"during manned mission mars, astronaut markwatney presumed dead after fierce storm , left behind hiscrew. watney has survived , finds himself stranded , alone onthe hostile planet. meager supplies, must draw upon hisingenuity, wit , spirit subsist , find way signal earththat alive.",          release_date:"2015-10-02",          genre_ids:[             18,             12,             878          ],          id:286217,          original_title:"the martian",          original_language:"en",          title:"the martian",          backdrop_path:"/sy3e2e4jwdatd2ozga2uuilze8j.jpg",          popularity:27.518041,          vote_count:2118,          video:false,          vote_average:7.63       },       {          poster_path:"/fqe8jxdno8b8qfogtdjh6spcdsc.jpg",          adult:false,          overview:"bountyhunters seek shelter raging blizzard , caught in aplot of betrayal , deception.",          release_date:"2015-12-25",          genre_ids:[             53,             37,             18,             9648          ],          id:273248,          original_title:"thehateful eight",          original_language:"en",          title:"the hateful eight",          backdrop_path:"/ssvgnbebnzaukl8u8sp50etjpgx.jpg",          popularity:26.55538,          vote_count:603,          video:false,          vote_average:7.13       },       {          poster_path:"/xpcna8zjxyyfktj47qpvkxhukzb.jpg",          adult:false,          overview:"during cold war, soviet union captures u.s. pilotfrancis gary powers after shooting down u-2 spy plane. sentencedto 10 years in prison, powers' hope new york lawyer jamesdonovan, recruited cia operative negotiate release.donovan boards plane berlin, hoping win young man'sfreedom through prisoner exchange. if goes well, russianswould rudolf abel, convicted spy donovan defended incourt.",          release_date:"2015-10-16",          genre_ids:[             53,             18          ],          id:296098,          original_title:"bridge of spies",          original_language:"en",          title:"bridge of spies",          backdrop_path:"/btgqcfmebgmkczr2zw7xo8wlhzk.jpg",          popularity:26.301868,          vote_count:455,          video:false,          vote_average:6.94       },       {          poster_path:"/kqjl17yufvn9ovlyxypvtyrffak.jpg",          adult:false,          overview:"anapocalyptic story set in furthest reaches of our planet, in astark desert landscape humanity broken, , iscrazed fighting necessities of life. within world existtwo rebels on run might able restore order. there'smax, man of action , man of few words, seeks peace of mindfollowing loss of wife , child in aftermath of thechaos. , furiosa, woman of action , woman believes herpath survival may achieved if can make across desertback childhood homeland.",          release_date:"2015-05-14",          genre_ids:[             53,             28,             12          ],          id:76341,          original_title:"mad max: furyroad",          original_language:"en",          title:"mad max: fury road",          backdrop_path:"/tbhdm8ujab4victsulyfl3lxmcd.jpg",          popularity:24.970694,          vote_count:3402,          video:false,          vote_average:7.49       },       {          poster_path:"/jjbgi2r5crt36xf6inuehzscecb.jpg",          adult:false,          overview:"twenty-two years after events of jurassic park, islanublar features functioning dinosaur theme park, jurassicworld, envisioned john hammond.",          release_date:"2015-06-12",          genre_ids:[             28,             12,             878,             53          ],          id:135397,          original_title:"jurassic world",          original_language:"en",          title:"jurassic world",          backdrop_path:"/dkmd5qlogermieixc4ynpuvax2t.jpg",          popularity:24.494238,          vote_count:3628,          video:false,          vote_average:6.74       },       {          poster_path:"/nbnzadxqjsdt05shlqgt0huc5gm.jpg",          adult:false,          overview:"interstellar chronicles adventures of group ofexplorers make use of newly discovered wormhole surpass thelimitations on human space travel , conquer vast distancesinvolved in interstellar voyage.",          release_date:"2014-11-05",          genre_ids:[             12,             18,             878          ],          id:157336,          original_title:"interstellar",          original_language:"en",          title:"interstellar",          backdrop_path:"/xu9zaaevzq5nnrsxn6jcahlng4i.jpg",          popularity:22.536403,          vote_count:4185,          video:false,          vote_average:8.24       },       {          poster_path:"/xw1gfkzxjgfm3dqok1swfchmfac.jpg",          adult:false,          overview:"the modern world holds many secrets, far mostastounding witches still live among us; vicious supernaturalcreatures intent on unleashing black death upon world andputting end human race once , all. armies of witchhunters have battled unnatural enemy centuries, includingkaulder, valiant warrior many years ago slayed all-powerfulwitch queen, decimating followers in process. in momentsright before death, queen cursed kaulder immortality,forever separating him beloved wife , daughter. today,kaulder last living hunter has spent immortal lifetracking down rogue witches, while yearning long-lostfamily.",          release_date:"2015-10-23",          genre_ids:[             14,             28,             12          ],          id:274854,          original_title:"the last witch hunter",          original_language:"en",          title:"the last witch hunter",          backdrop_path:"/o6saqjlagkpczr0yhjkei9fnwn7.jpg",          popularity:21.925333,          vote_count:282,          video:false,          vote_average:5.49       },       {          poster_path:"/5ju9ytzjyr3zmclgmvm9q4geqbd.jpg",          adult:false,          overview:"the yearis 2029. john connor, leader of resistance continues waragainst machines. @ los angeles offensive, john's fears ofthe unknown future begin emerge when tecom spies reveal new plotby skynet attack him both fronts; past , future, andwill change warfare forever.",          release_date:"2015-07-01",          genre_ids:[             878,             28,             53,             12          ],          id:87101,          original_title:"terminatorgenisys",          original_language:"en",          title:"terminator genisys",          backdrop_path:"/bilyh4l2ayyveysms2aofjo7dn8.jpg",          popularity:20.298683,          vote_count:1656,          video:false,          vote_average:6.14       },       {          poster_path:"/q0r4crx2sehceeqekyobktdefy.jpg",          adult:false,          overview:"minions stuart, kevin , bob recruited scarletoverkill, super-villain who, alongside inventor husband herb,hatches plot take on world.",          release_date:"2015-07-10",          genre_ids:[             10751,             16,             12,             35          ],          id:211672,          original_title:"minions",          original_language:"en",          title:"minions",          backdrop_path:"/ux7lxnsc7bzjzjn048ucowkpxwj.jpg",          popularity:19.456371,          vote_count:2105,          video:false,          vote_average:6.7       },       {          poster_path:"/vq7ovx2j7bnmdyyzufeg1epqvgb.jpg",          adult:false,          overview:"70-year-old widower ben whittaker has discovered retirementisn't it's cracked be. seizing opportunity inthe game, becomes senior intern @ online fashion site,founded , run jules ostin.",          release_date:"2015-09-25",          genre_ids:[             35          ],          id:257211,          original_title:"the intern",          original_language:"en",          title:"the intern",          backdrop_path:"/nyl1fnn9jguxgttdl8tes75fsf8.jpg",          popularity:18.867295,          vote_count:491,          video:false,          vote_average:7.05       },       {          poster_path:"/yivnnriiyl522hk3lfljrrmovhp.jpg",          adult:false,          overview:"the truestory of whitey bulger, brother of state senator , mostinfamous violent criminal in history of south boston, becamean fbi informant take down mafia family invading turf.",          release_date:"2015-09-18",          genre_ids:[             80,             18          ],          id:261023,          original_title:"black mass",          original_language:"en",          title:"blackmass",          backdrop_path:"/yu0v8xnqmecoto4exyxsnp7n7kw.jpg",          popularity:18.190746,          vote_count:403,          video:false,          vote_average:5.96       },       {          poster_path:"/vgahvs0bt3fpcpnjqt6udtushto.jpg",          adult:false,          overview:"immediately after events of desolation of smaug,bilbo , dwarves try defend erebor's mountain of treasure fromothers claim it: men of ruined laketown , elves ofmirkwood. meanwhile army of orcs led azog defiler ismarching on erebor, fueled rise of dark lord sauron.dwarves, elves , men must unite, , hope middle-earth fallsinto bilbo's hands.",          release_date:"2014-12-17",          genre_ids:[             12,             14          ],          id:122917,          original_title:"the hobbit: battle of fivearmies",          original_language:"en",          title:"the hobbit: battle ofthe 5 armies",          backdrop_path:"/qhh3gyifangv1pjdv3mw03qailg.jpg",          popularity:16.720462,          vote_count:2343,          video:false,          vote_average:7.14       },       {          poster_path:"/d6e8rjf2qustnfktsltxntualt.jpg",          adult:false,          overview:"armed astonishing ability shrink inscale increase in strength, con-man scott lang must embrace hisinner-hero , mentor, dr. hank pym, protect secretbehind spectacular ant-man suit new generation of toweringthreats. against seemingly insurmountable obstacles, pym , lang mustplan , pull off heist save world.",          release_date:"2015-07-17",          genre_ids:[             878,             28,             12          ],          id:102899,          original_title:"ant-man",          original_language:"en",          title:"ant-man",          backdrop_path:"/kvxlzqy0ngl1xsw7eamqo0c1ccj.jpg",          popularity:16.448005,          vote_count:2414,          video:false,          vote_average:6.88       },       {          poster_path:"/nxxi1mcj0ugmetj5qn7ofdxanxf.jpg",          adult:false,          overview:"suave,charming , volatile, reggie kray , unstable twin brotherronnie start leave mark on london underworld in the1960s. using violence want, siblings orchestraterobberies , murders while running nightclubs , protection rackets.with police detective leonard "         nipper" read hot on heels,          thebrothers continue rapid rise power , achieve tabloidnotoriety.",          release_date:"2015-09-09",          genre_ids:[             80,             53          ],          id:276907,          original_title:"legend",          original_language:"en",          title:"legend",          backdrop_path:"/zazdejblqsywujy2tqkso1anvwn.jpg",          popularity:15.78096,          vote_count:155,          video:false,          vote_average:6.75       },       {          poster_path:"/vltpqanjlytebzfjm1g4keon0cb.jpg",          adult:false,          overview:"thomas , fellow gladers face greatestchallenge yet: searching clues mysterious , powerfulorganization known wckd. journey takes them scorch, adesolate landscape filled unimaginable obstacles. teaming withresistance fighters, gladers take on wckd’s vastly superior forcesand uncover shocking plans them all.",          release_date:"2015-09-18",          genre_ids:[             53,             28,             878          ],          id:294254,          original_title:"maze runner: scorch trials",          original_language:"en",          title:"maze runner: scorch trials",          backdrop_path:"/iaprfmgkvn9tsjqpln7midtcezg.jpg",          popularity:15.521757,          vote_count:1006,          video:false,          vote_average:6.56       },       {          poster_path:"/cwerd8rgbw7bcmzlwp207huxxym.jpg",          adult:false,          overview:"katnisseverdeen reluctantly becomes symbol of mass rebellion againstthe autocratic capitol.",          release_date:"2014-11-21",          genre_ids:[             878,             12,             53          ],          id:131631,          original_title:"the hunger games:mockingjay - part 1",          original_language:"en",          title:"the hungergames: mockingjay - part 1",          backdrop_path:"/fun5i5f4069vwgfeeva3hxt9xpp.jpg",          popularity:15.521613,          vote_count:2426,          video:false,          vote_average:6.86       },       {          poster_path:"/aamfix3tt40zuhgcckrlozrkc7u.jpg",          adult:false,          overview:"growingup can bumpy road, , it's no exception riley, isuprooted midwest life when father starts new job in sanfrancisco. of us, riley guided emotions - joy,fear, anger, disgust , sadness. emotions live in headquarters,the control center inside riley's mind, advise herthrough everyday life. riley , emotions struggle adjust toa new life in san francisco, turmoil ensues in headquarters. althoughjoy, riley's main , important emotion, tries keep thingspositive, emotions conflict on how best navigate new city,house , school.",          release_date:"2015-06-19",          genre_ids:[             35,             16,             10751          ],          id:150540,          original_title:"inside out",          original_language:"en",          title:"inside out",          backdrop_path:"/szytsplaybh3ulei3x663mav5zt.jpg",          popularity:14.92858,          vote_count:2415,          video:false,          vote_average:8.04       }    ],    total_results:252862,    total_pages:12644 } 

public void parsepopularmoviejson(string json) throws jsonexception {     jsonobject popularmovies = new jsonobject(json);     jsonarray results = popularmovies.getjsonarray("results");      (int = 0; < results.length(); i++) {         jsonobject currentmovie = results.getjsonobject(i);         movie movie = new movie();          movie.setposterpath(currentmovie.getstring("poster_path"));         movie.setoverview(currentmovie.getstring("overview"));         movie.setreleasedate(currentmovie.getstring("release_date"));         movie.setoriginaltitle(currentmovie.getstring("original_title"));         movie.setvoteaverage(currentmovie.getdouble("vote_average"));         mimageurl[i] = movie.getposterpath();         movies.add(movie);     } } 

according debugger, going loop popularmovies object equal entire string , results equal main array inside string. @ point during first iteration of loop error beside either popularmovies or results stating object has been collected cannot evaluate jsonobject(array).tostring().

i have been debugging hours , cannot understand why happening. if please provide insight why occurring in middle of loop appreciated! thanks!

[solution]: json not formatted. thank pointing out. apologies ignorance, new json format!

use java exception breakpoint ctrl+shift+f8 , enable exception breakpoint


Comments