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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:21:30+00:00 2026-06-06T17:21:30+00:00

Hi am new to JSON and I will like to retrieve the values for

  • 0

Hi am new to JSON and I will like to retrieve the values for the json below

{"error":"0","uid":"160","langId":"2","rank":"1"}

I wrote a JSONParser class, but the main activity class has got me stuck. Below is the code

private static final String LOGTAG = "MyActivity";
    private static String JSONurl = "http://www.afroklore.org/mobile/boot.php?actn=post_prov&lang=1&uid=2&prov=";
    private static final String ERROR = "error";
    private static final String UID = "uid";
    private static final String LANGID = "langId";
    private static final String RANK = "rank";
    JSONArray output = null;
    String id, error, langId, rank;

if (MenuActivity.status == 2) {
            JSONParser jParser = new JSONParser();
            JSONObject json = jParser.getJSONFromUrl(JSONurl);

            try {
                output = json.getJSONArray(ERROR);

                for (int i = 0; i < output.length(); i++) {
                    JSONObject c = output.getJSONObject(i);

                    // Storing each json item in variable
                    id = c.getString(UID);
                    error = c.getString(ERROR);
                    langId = c.getString(LANGID);
                    rank = c.getString(RANK);
                    // creating new HashMap
                    /*
                    HashMap<String, String> map = new HashMap<String, String>();

                    // adding each child node to HashMap key => value
                    map.put(ERROR, error);
                    map.put(UID, id);
                    map.put(LANGID, langId);
                    map.put(RANK, rank);

                    // adding HashList to ArrayList
                    outputField.add(map);*/
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        return result;

protected void onPostExecute(String r) {
            // TODO Auto-generated method stub
            super.onPostExecute(result);
            String msg = "Login successful";

            if (MenuActivity.status == 2) {
                Log.d(LOGTAG, result);
                // Log.d(LOGTAG, outputField.get(ERROR));
                Log.d(LOGTAG, error + " " + id + " " + langId + " " + rank);

}

  • 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-06T17:21:33+00:00Added an answer on June 6, 2026 at 5:21 pm

    Check your json webservice respose here.it’s containing only one json object as string provided by you

    {"error":"0","uid":"160","langId":"2","rank":"1"}
    

    so parse it as

    JSONObject json = jParser.getJSONFromUrl(JSONurl);
         try {
             // Storing each json item in variable
             id = json.getString(UID);
             error = json.getString(ERROR);
             langId = json.getString(LANGID);
             rank = json.getString(RANK);
               //..your code here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How would like a class that will return a json format. This method work
I want to add new obj of JSON like: 128: { Msg: [{ me:
My JSON contains special characters like: new line, double quotes etc. I am creating
I wish to use JSON.Net on a brand spankin new Mono class library (say
i will like to pass pictureActivity.java array to another class imageAdapter.java. I do get
I need to set/initialize an array exactly to what JSON will look like so
am new to Json so a little green. I have a Rest Based Service
Im new to JSON and php. I need to grab the lat and lng
I am new to JSON programming in J2ME. I discovered that Json is used
I'm new with JSON.NET and I'm trying to deserialize a JSON string to a

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.