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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:14:24+00:00 2026-06-07T10:14:24+00:00

I am trying to get JSON data from a string that I have created

  • 0

I am trying to get JSON data from a string that I have created from data I have pulled down from a URL. So far this is what I have in my code:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final TextView tv = (TextView)findViewById(R.id.result);

        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);

        String username = "username";
        String password = "password";
        String url = "http://www.example.com/api/core/v1/my/";
        String unp = username+":"+password;


        class MyUser {
              public String firstName;
              public String lastName;
        }


        try {
            HttpClient client = new DefaultHttpClient();
            HttpGet header = new HttpGet(url);
            String encoded_login = Base64.encodeToString(unp.getBytes(), Base64.NO_WRAP);
            header.setHeader(new BasicHeader("Authorization", "Basic "+encoded_login));
            HttpResponse response = client.execute(header);
            HttpEntity entity = response.getEntity();

            BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
            for (String line; (line = reader.readLine()) != null;line.replaceAll("throw 'allowIllegalResourceCall is false.';", "")) {
                Vector<Object> vector = new Vector<Object>();
                vector.add(line);
                String result = vector.toString();


                JSONObject json = (JSONObject)new JSONParser().parse(result);
                System.out.println("name=" + json.get("name"));
                System.out.println("width=" + json.get("width"));

                System.out.println(line);
            }       


        } catch (Exception e) {
            e.printStackTrace();
            Log.d(MY_APP_TAG, "Error e: " + e);
        }

        }

This is pulling the correct json data down, but every time i try to parse the data i am getting the following:

E/AndroidRuntime(923): FATAL EXCEPTION: main
E/AndroidRuntime(923): java.lang.NoClassDefFoundError: org.json.simple.parser.JSONParser
E/AndroidRuntime(923): at basic.authentication.BasicAuthenticationActivity.onCreate(BasicAuthenticationActivity.java:85)
E/AndroidRuntime(923): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(923): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime(923): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime(923): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime(923): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime(923): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime(923): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(923): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(923): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime(923): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(923): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(923): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime(923): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime(923): at dalvik.system.NativeStart.main(Native Method)

I am new to JSON so figuring this out is proving a real big challenge so any help with this is much appreciated.

Also, the JSON data come through like this:

{
  "enabled" : true,
  "email" : "example@gmail.com",
  "firstName" : "example firstname",
  "lastName" : "example lastname",
  "name" : "example fullname",
  "level" : {

I know that these are JSON objects and not JSON arrays.

  • 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-07T10:14:26+00:00Added an answer on June 7, 2026 at 10:14 am

    Why don’t you create a JSon object using your string, like this:

         JSONObject jsonObject = new JSONObject(result);
    

    Now, get the desired value like this:

         String name = jsonObject.getString("name");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a json string back from my controller, that is prefill-values
I have an JSON string that gets returned from the server that i'm trying
I have a JSON string (from PHP's json_encode() that looks like this: [{id: 1,
I have a web service and I'm trying to get data by JSON. if
I'm trying to get the JSON object from a JSON outputted string from a
I have a function var url = MyAvailability.aspx?mode=get; $.get(url, function(data) { alert(data); }); that
I'm trying to call this URL with an android httpget to have a json
Im trying to figure out a way to get some JSON data transfered from
I'm trying to get some json data in my application, but it won't come
I'm trying to get a JSON response and iterate through the data. Here is

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.