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

  • Home
  • SEARCH
  • 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 6991641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:31:48+00:00 2026-05-27T19:31:48+00:00

I have created an string in JSON format. It looks like: private String jString

  • 0

I have created an string in JSON format. It looks like:

private String jString = "{\"CategoryId\":1},{\"CategoryId\":2}";

and this is then initialized as an JSON object like this:

JSONObject jObject = new JSONObject(jString);

when reading I’m using:

j = jObject.getString("CategoryId");

I can read the first value but I can’t read the second one. Any ideas on how to solve?

  • 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-05-27T19:31:49+00:00Added an answer on May 27, 2026 at 7:31 pm

    This is not a valid JSON format. Look here to see the format of a JSON object / array.

    If you want to be able to read both values, create an array:

    String jString = "[{\"CategoryId\":1},{\"CategoryId\":2}]";
    JSONArray jArr = new JSONArray(jString);
    for (int i = 0; i < jArr.length(); ++i) {
        int i = jArr.getJsonObject(i).getInt("CategoryId");
        // do something with i which is an int, not a String
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JSON String in this format: { supplier: { mov_10: love actually,
Say I have a structure like: class SomeObject Public Name as String Public Created
I have a model that looks something like this class Post(models.Model): id = models.IntegerField(unique=True,
I have a serialized json string in the format: [{\Version\:\8.63\,\Date\:\07\/11\/2011 00:00:00\,\Count\:213}, {\Version\:\1.0\,\Date\:\07\/11\/2011 00:00:00\,\Count\:1}, .........
I have a JSON object created in PHP, that JSON object contains another escaped
I have created a code like this to access method AddNums in my webservice.
Ok, a little new to JSON format.. I have the following JSON string returned
I have created a series of resource (resx) files to hold language specific string
I want to store data in string form to MySQL. I have created the
I have a string like following: CREATE GLOBAL TEMPORARY TABLE some_temp_table_name or CREATE GLOBAL

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.