Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Getting Error "org.json.JSONException: Unterminated string at character" when parsing Json Data

Hey Guys , I get an error " org.json.JSONException: Unterminated string at character" when i try to parse the Json data from api's like api.ihackernews.com/page or http://api.dribbble.com/shots . But strangely the code seems to work for example api - http://blog.teamtreehouse.com/api/get_recent_summary/ . Please help.

4 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

There are two threads in the forum that talk about this exact issue. There's a bug in the code from the videos for certain other feeds, so I need to figure out how to update that for the future. Until then, this first post should have a solution you can use, and I'm linking the second for additional discussion (if you care): :smile:

Awesome ! thanks Ben.

Ben Jakuben Hi Ben, I am getting the same error... i experimented with it... it showing error when character goes beyond 2000 So if we decrease the number of posts to 5 its displaying. I dont Know i will ever get the answer or not.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

Yep - sorry about the issue! Check the first link I posted above. It has alternative code that fixes the bug.

Ben Jakuben Thank you sir. But by using the same code i solved the issue.. i researched your json format and there was a "thumbnail" : which was returning null value so i created a String thumbnail = post.getString("thumbnail"); thumbnail = Html.fromHtml("thumbnail").toString();

and it worked :)