Json Exception: Org.json.jsonexception: Unterminated Array
I'm working on an android app - which requests some data from server and the server returns data in JSON format. Everything works fine, except an API. After debugging, I've found t
Solution 1:
I see something wrong:
The elements in the array should be separated with commas:
{
"total":"2",
"result": [
{
"id":"15",
"ename":"Horror movies based on true stories",
"vname":"Nh?ng phim kinh d? du?a tren chuye?n co? tha?t",
"movies":"16"
}**,COMMA**
{
"id":"14",
"ename":"IMDB Top 250","vname":"250 b? phim hay nh?t m?i th?i d?i",
"movies":"127"
}
]
}
Note that I placed the string COMMA
just to underline the place. You need to add only ,
without COMMA
.
Solution 2:
When you want to use quotes in your json you must must use escaped quotes. Like this:
[{"vname": "Tuyển tập \"Trởlạitươnglai\""}]
Solution 3:
your response must be like this
{"total":"2","result":[{"id":"15","ename":"Horror movies based on true stories","vname":"Những phim kinh dị dựa trên chuyện có thật","movies":"16"},{"id":"14","ename":"IMDB Top 250","vname":"250 bộ phim hay nhất mọi thời đại","movies":"127"},{"id":"13","ename":"10 good movies for women","vname":"10 bộ phim hay dành cho phái đẹp","movies":"10"},{"id":"12","ename":"The 84th Annual Academy Awards","vname":"Giải Oscars lần thứ 84 (2012)","movies":"37"},{"id":"11","ename":"Charlie Chaplin collection","vname":"Tuyển tập hề Sác lô","movies":"7"},{"id":"10","ename":"Tuyển tập điệp viên 007","vname":"007 collection","movies":"23"},{"id":"9","ename":"Donnie Yen movies collection","vname":"Tuyển tập phim Chung Tử Đơn","movies":"24"},{"id":"8","ename":"Back to the Future trilogy","vname":"Tuyển tập Trởlạitươnglai","movies":"3"},{"id":"7","ename":"StiegLarssonsMillenniumtrilogy","vname":"BộtiểuthuyếtMilleniumcủanhàvănStiegLarsson","movies":"3"},{"id":"6","ename":"ChanWookParksvengeancetrilogy","vname":"BộbaphimBáothùcủađạodiễnParkChanWook","movies":"3"}]}
and moreover your one value contains "
extra Trở lại tương lai
so just remove that.
Solution 4:
Does this help? Android: Json string with spaces gives "Unterminated object at" exception
Seems like you need to look up some examples of how JSON arrays are formed.
Solution 5:
here is you json array you are missing comma after each element in your Jsonarray result
you can check you JSON whether its valid or not here or here
{
"total": "2",
"result": [
{
"id": "15",
"ename": "Horror movies based on true stories",
"vname": "Những phim kinh dị dựa trên chuyện có thật",
"movies": "16"
}{
"id": "14",
"ename": "IMDB Top 250",
"vname": "250 bộ phim hay nhất mọi thời đại",
"movies": "127"
}{
"id": "13",
"ename": "10 good movies for women",
"vname": "10 bộ phim hay dành cho phái đẹp",
"movies": "10"
}{
"id": "12",
"ename": "The 84th Annual Academy Awards",
"vname": "Giải Oscars lần thứ 84 (2012)",
"movies": "37"
}{
"id": "11",
"ename": "Charlie Chaplin collection",
"vname": "Tuyển tập hề Sác lô",
"movies": "7"
}{
"id": "10",
"ename": "Tuyển tập điệp viên 007",
"vname": "007 collection",
"movies": "23"
}{
"id": "9",
"ename": "Donnie Yen movies collection",
"vname": "Tuyển tập phim Chung Tử Đơn",
"movies": "24"
}{
"id": "8",
"ename": "Back to the Future trilogy",
"vname": "Tuyển tập "Trởlạitươnglai"",
"movies": "3"
}{
"id": "7",
"ename": "Stieg Larssons Millennium trilogy",
"vname": "Bộ tiểu thuyết Millenium của nhà văn Stieg Larsson",
"movies": "3"
}{
"id": "6",
"ename": "Chan Wook Parks vengeance trilogy",
"vname": "Bộ ba phim Báo thù của đạo diễn Park Chan Wook",
"movies": "3"
}
]
}
Post a Comment for "Json Exception: Org.json.jsonexception: Unterminated Array"