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 6923657
In Process

The Archive Base Latest Questions

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

I have a little question about parsing a JSON string in Android. I’m trying

  • 0

I have a little question about parsing a JSON string in Android. I’m trying to parse this JSON :

{
   "error":504,
   "result":"[\"USRL3C4NAEL84727\",\"USR1HZE4UN5289H1\",\"USR46476WQB92M84\",\"USR4ZQ193YGRK782\"]"
}

The part that I need actually is to parse the result. I did try this :

JSONObject jObj = new JSONObject(responseString);
            int error = Integer.parseInt(jObj.optString("error","0"));
            String errorMessage = jObj.optString("result","");
            if(error==504){
                JSONArray savedCodes = jObj.getJSONArray("result");
                for (int i = 0; i < savedCodes.length(); i++) {
                    String returnString = savedCodes.getString(i);
                    Log.e("","returnString : "+returnString);
                }
            }

But it’s throwing me an exception :

org.json.JSONException: Value ["USR9BA13IZG27H93","USRI818369RH919Y","USRWT7612CQV4375","USR7739R644X84A1"] at result of type java.lang.String cannot be converted to JSONArray

So I guess it’s not JSONArray and I need to know how to parse the result part and get this at the end :

String 1 = USR9BA13IZG27H93
String 2 = USRI818369RH919Y
and etc...

Any solutions?

  • 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-27T10:33:49+00:00Added an answer on May 27, 2026 at 10:33 am

    The easiest way to do this :

    String errorMessage = jObj.optString("result","");
    if(error==504){
         String first = errorMessage.replace("[", "");
         String second = first.replace("]", "");
         String third = second.replace("\"", "");
         String[] split = third.split(",");
    
         for(int i=0;i< split.length;i++)
             Log.e("","SPLIT : "+split[i]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little question about how web browser retrieve webpage? I know this User
I have a question about PHP Class. I am trying to get the result
So, this question may be a little vague, but I have constant discussions about
I have this little question that's been on my mind for a while now.
This question may seem a little bit stackoverflow-implementation specific, but I have seen a
I am trying out a little reflection and have a question on how the
i have a little question about the verbatim environment in latex..... my problem is
Forgive me if this question makes little sense; I have had little sleep as
I have a little question about creating a table using another tables. my code:
Ні, all! I have a little question about jQuery.Validation plugin: - Can I complete

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.