Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8049747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:52:07+00:00 2026-06-05T06:52:07+00:00

I am trying to parse a json into my list view. I don’t no

  • 0

I am trying to parse a json into my list view. I don’t no what is the problem? but i got an exception telling me that Names must be Strings and must be unique within an object.

Here is my code:

try {

            jsonString =  "{[{\"url\":\"www.200Chess.com\",\"price\":\"Free\",\"name\":\"200 Chess Opening\"},{\"url\":\"www.midgame.com\",\"price\":\"10$\",\"name\":\"Mid Game TacHcs\"},{\"url\":\"www.303checkmate.com\",\"price\":\"20$\",\"name\":\"303 Checkmate puzzles\"},{\"url\":\"www.303winning.com\",\"price\":\"30$\",\"name\":\"303 Winning Strategies\"},{\"url\":\"www.bibby.com\",\"price\":\"10$\",\"name\":\"Bobby Fusher Teaches Chess\"}]}";

            json= new JSONObject(jsonString);

            JSONArray jsonBook = json.getJSONArray("");

            for (int i=0; i<jsonBook.length();i++){

                Book book =new Book();

                JSONObject jsonAttributes = jsonBook.getJSONObject(i).getJSONObject("");

                Log.i("ListBooks", jsonAttributes.toString());

                book.name = jsonAttributes.getString(KEY_NAME);

                Log.i("ListBooks", book.name);

                book.price = jsonAttributes.getString(KEY_PRICE);

                book.url = jsonAttributes.getString(KEY_URL);

                books.add(book);

            }

        } catch (JSONException e) {

            e.printStackTrace();

        }

I got this exception:

06-05 21:59:42.283: W/System.err(541): org.json.JSONException: Names must be strings, but [{"url":"www.200Chess.com","name":"200 Chess Opening","price":"Free"},{"url":"www.midgame.com","name":"Mid Game TacHcs","price":"10$"},{"url":"www.303checkmate.com","name":"303 Checkmate puzzles","price":"20$"},{"url":"www.303winning.com","name":"303 Winning Strategies","price":"30$"},{"url":"www.bibby.com","name":"Bobby Fusher Teaches Chess","price":"10$"}] is of type org.json.JSONArray at character 361 of {[{"url":"www.200Chess.com","price":"Free","name":"200 Chess Opening"},{"url":"www.midgame.com","price":"10$","name":"Mid Game TacHcs"},{"url":"www.303checkmate.com","price":"20$","name":"303 Checkmate puzzles"},{"url":"www.303winning.com","price":"30$","name":"303 Winning Strategies"},{"url":"www.bibby.com","price":"10$","name":"Bobby Fusher Teaches Chess"}]}
06-05 21:59:42.283: W/System.err(541):  at org.json.JSONTokener.syntaxError(JSONTokener.java:446)
06-05 21:59:42.293: W/System.err(541):  at org.json.JSONTokener.readObject(JSONTokener.java:363)
06-05 21:59:42.293: W/System.err(541):  at org.json.JSONTokener.nextValue(JSONTokener.java:96)
06-05 21:59:42.293: W/System.err(541):  at org.json.JSONObject.<init>(JSONObject.java:154)
06-05 21:59:42.293: W/System.err(541):  at org.json.JSONObject.<init>(JSONObject.java:171)
06-05 21:59:42.293: W/System.err(541):  at tn.haythem.learnchess.ListBooks.getBooks(ListBooks.java:157)
06-05 21:59:42.293: W/System.err(541):  at tn.haythem.learnchess.ListBooks.onCreate(ListBooks.java:52)
06-05 21:59:42.293: W/System.err(541):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-05 21:59:42.293: W/System.err(541):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-05 21:59:42.303: W/System.err(541):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-05 21:59:42.303: W/System.err(541):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-05 21:59:42.303: W/System.err(541):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-05 21:59:42.313: W/System.err(541):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-05 21:59:42.313: W/System.err(541):  at android.os.Looper.loop(Looper.java:123)
06-05 21:59:42.313: W/System.err(541):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-05 21:59:42.313: W/System.err(541):  at java.lang.reflect.Method.invokeNative(Native Method)
06-05 21:59:42.313: W/System.err(541):  at java.lang.reflect.Method.invoke(Method.java:507)
06-05 21:59:42.313: W/System.err(541):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-05 21:59:42.313: W/System.err(541):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-05 21:59:42.323: W/System.err(541):  at dalvik.system.NativeStart.main(Native Method)

Can any body please tell me what is wrong in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:52:08+00:00Added an answer on June 5, 2026 at 6:52 am

    The array in the JSON object has no name, which is not valid, e.g. it should start like this:

    "{\"thearrayname\":[{\"url\":\"www.200Chess.com\",\" ...
    

    or remove the outer { and } and parse it as a JSONArray directly e.g.:

    [{\"url\":\"www.200Chess.com\",\" ... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to parse Json into A ListView but when i do
I'm trying to load and parse json data from an external source into a
I'm trying to parse the json response from the Google Geocode API but I'm
I'm trying to parse JSON into NSDictionary. I have tried a lot of different
I am trying to parse a JSON object into a Python dict . I've
http://pastebin.com/rXbeKqAa Hi all I have been trying to parse the above JSON into a
I'm trying to parse JSON string using Boost Spirit store JSON object into recursive
I'm trying to parse an array of JSON objects into an array of strings
I am trying to parse a json string straight into a managed object. The
I'm currently trying to parse JSON into Core Data objects. I parse the JSON

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.