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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:48:23+00:00 2026-05-26T20:48:23+00:00

I am trying to get a response from my server using restful services, I

  • 0

I am trying to get a response from my server using restful services, I get it back in json format, change to a string variable then am trying to change from a string variable to json object, but I am getting an error here is my class and after my class is my stacktrace and then my string variable, the error occurs when i try to convert from string to json object, thanks for your help:

private class DownloadWebPageTask extends AsyncTask<String, Void, String> {
        @Override
        protected String doInBackground(String... urls) {
            String response = "";
            for (String url : urls) {
                DefaultHttpClient client = new DefaultHttpClient();
                HttpGet httpGet = new HttpGet(url);
                try {
                    HttpResponse execute = client.execute(httpGet);
                    InputStream content = execute.getEntity().getContent();

                    BufferedReader buffer = new BufferedReader(
                            new InputStreamReader(content));
                    String s = "";
                    while ((s = buffer.readLine()) != null) {
                        response += s;
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            try {
                //JSONObject json = new JSONObject(response);
                JSONObject data = new JSONObject(response).getJSONObject("type");

            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            return response;
        }

11-14 09:53:26.192: W/System.err(560): org.json.JSONException: Value
[{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0373889/&#8221;,”label”:”Harry
Potter und der Orden des
Phonix”,”videoinfo”:{“id”:”humvideo:0373889″,”title”:”Harry Potter und
der Orden des
Phonix”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry
Potter,magic”,”description”:”Lord Voldemort ist zuruckgekehrt, doch
das Zaubereiministerium tut alles, um diese Tatsache der Geme
…”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2007-04-11″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0330373/&#8221;,”label”:”Harry
Potter und der
Feuerkelch”,”videoinfo”:{“id”:”humvideo:0330373″,”title”:”Harry Potter
und der
Feuerkelch”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry
Potter,magic”,”description”:”Das grosse Abenteuer beginnt, als der
Feuerkelch Harry Potters Namen freigibt und Harry damit Teilne
…”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2005-11-18″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0304141/&#8221;,”label”:”Harry
Potter und der Gefangene von
Askaban”,”videoinfo”:{“id”:”humvideo:0304141″,”title”:”Harry Potter
und der Gefangene von
Askaban”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry
Potter,magic”,”description”:”Wahrend die abscheuliche Tante Magda uber
den Nachthimmel schwebt, kehrt Harry nach Hogwarts zuruck,
…”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2003-06-04″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0295297/&#8221;,”label”:”Harry
Potter und die Kammer
Desschreckens”,”videoinfo”:{“id”:”humvideo:0295297″,”title”:”Harry
Potter und die Kammer
Desschreckens”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry
Potter,magic”,”description”:”Fliegende Autos, gemeingefahrliche Baume
und die Warnung eines mysteriosen Hauselfen – so beginnt fu
…”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2002-11-15″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0241527/&#8221;,”label”:”Harry
Potter und der Stein der
Weisen”,”videoinfo”:{“id”:”humvideo:0241527″,”title”:”Harry Potter und
der Stein der
Weisen”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry
Potter,magic”,”description”:”In der zauberhaften Verfilmung J.K.
Rowlings Weltbestseller erfahrt Harry Potter an seinem 11. Gebur
…”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2001-11-16″}}]
of type org.json.JSONArray cannot be converted to JSONObject 11-14
09:53:26.232: W/System.err(560): at
org.json.JSON.typeMismatch(JSON.java:111) 11-14 09:53:26.242:
W/System.err(560): at org.json.JSONObject.(JSONObject.java:158)
11-14 09:53:26.252: W/System.err(560): at
org.json.JSONObject.(JSONObject.java:171) 11-14 09:53:26.262:
W/System.err(560): at
de.vogella.android.asynctask.ReadWebpageAsyncTask$DownloadWebPageTask.doInBackground(ReadWebpageAsyncTask.java:56)
11-14 09:53:26.332: W/System.err(560): at
de.vogella.android.asynctask.ReadWebpageAsyncTask$DownloadWebPageTask.doInBackground(ReadWebpageAsyncTask.java:1)
11-14 09:53:26.352: W/System.err(560): at
android.os.AsyncTask$2.call(AsyncTask.java:264) 11-14 09:53:26.372:
W/System.err(560): at
java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-14 09:53:26.382: W/System.err(560): at
java.util.concurrent.FutureTask.run(FutureTask.java:137) 11-14
09:53:26.392: W/System.err(560): at
android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 11-14
09:53:26.402: W/System.err(560): at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-14 09:53:26.412: W/System.err(560): at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-14 09:53:26.422: W/System.err(560): at
java.lang.Thread.run(Thread.java:856) 11-14 09:53:34.635:
D/dalvikvm(169): GC_CONCURRENT freed 396K, 7% free 7350K/7879K, paused
21ms+9ms

string variable:

[ { “type”: “HumVideoMovingImage”,
“videoinfo”: { “status”: “allowed”,
“description”: “Lord Voldemort ist zuruckgekehrt, doch das
Zaubereiministerium tut alles, um diese Tatsache der Geme …”,
“height”: 480, “coverage”: “BYU”, “date”:
“2007-04-11”, “id”: “humvideo:0373889”,
“subject”: “Harry Potter,magic”, “language”: [“de”],
“rights”: “shared”, “title”: “Harry Potter und der Orden
des Phonix”, “runningtime”: 7200, “width”: 716
}, “location”:
“http://hummedia.byu.edu/watch/humvideo:0373889/&#8221;, “label”:
“Harry Potter und der Orden des Phonix” }, {
“type”: “HumVideoMovingImage”, “videoinfo”: {
“status”: “allowed”, “description”: “Das grosse Abenteuer
beginnt, als der Feuerkelch Harry Potters Namen freigibt und Harry
damit Teilne …”, “height”: 480, “coverage”:
“BYU”, “date”: “2005-11-18”, “id”:
“humvideo:0330373”, “subject”: “Harry Potter,magic”,
“language”: [“de”], “rights”: “shared”,
“title”: “Harry Potter und der Feuerkelch”,
“runningtime”: 7200, “width”: 716 },
“location”: “http://hummedia.byu.edu/watch/humvideo:0330373/&#8221;,
“label”: “Harry Potter und der Feuerkelch” }, {
“type”: “HumVideoMovingImage”, “videoinfo”: {
“status”: “allowed”, “description”: “Wahrend die
abscheuliche Tante Magda uber den Nachthimmel schwebt, kehrt Harry
nach Hogwarts zuruck, …”, “height”: 480,
“coverage”: “BYU”, “date”: “2003-06-04”,
“id”: “humvideo:0304141”, “subject”: “Harry
Potter,magic”, “language”: [“de”], “rights”:
“shared”, “title”: “Harry Potter und der Gefangene von
Askaban”, “runningtime”: 7200, “width”: 716
}, “location”:
“http://hummedia.byu.edu/watch/humvideo:0304141/&#8221;, “label”:
“Harry Potter und der Gefangene von Askaban” },
{ “type”: “HumVideoMovingImage”, “videoinfo”: {
“status”: “allowed”, “description”: “Fliegende Autos,
gemeingefahrliche Baume und die Warnung eines mysteriosen Hauselfen –
so beginnt fu …”, “height”: 480, “coverage”:
“BYU”, “date”: “2002-11-15”, “id”:
“humvideo:0295297”, “subject”: “Harry Potter,magic”,
“language”: [“de”], “rights”: “shared”,
“title”: “Harry Potter und die Kammer Desschreckens”,
“runningtime”: 7200, “width”: 716 },
“location”: “http://hummedia.byu.edu/watch/humvideo:0295297/&#8221;,
“label”: “Harry Potter und die Kammer Desschreckens” },
{ “type”: “HumVideoMovingImage”, “videoinfo”: {
“status”: “allowed”, “description”: “In der zauberhaften
Verfilmung J.K. Rowlings Weltbestseller erfahrt Harry Potter an seinem
11. Gebur …”, “height”: 480, “coverage”: “BYU”, “date”: “2001-11-16”, “id”:
“humvideo:0241527”, “subject”: “Harry Potter,magic”,
“language”: [“de”], “rights”: “shared”,
“title”: “Harry Potter und der Stein der Weisen”,
“runningtime”: 7200, “width”: 716 },
“location”: “http://hummedia.byu.edu/watch/humvideo:0241527/&#8221;,
“label”: “Harry Potter und der Stein der Weisen” }

    ]

by trying to use the following code:
JSONObject jObject = new JSONObject(response);

I still get an error, here is the stack trace:

11-14 10:03:02.713: W/System.err(622): org.json.JSONException: Value [{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0373889/&#8221;,”label”:”Harry Potter und der Orden des Phonix”,”videoinfo”:{“id”:”humvideo:0373889″,”title”:”Harry Potter und der Orden des Phonix”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry Potter,magic”,”description”:”Lord Voldemort ist zuruckgekehrt, doch das Zaubereiministerium tut alles, um diese Tatsache der Geme …”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2007-04-11″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0330373/&#8221;,”label”:”Harry Potter und der Feuerkelch”,”videoinfo”:{“id”:”humvideo:0330373″,”title”:”Harry Potter und der Feuerkelch”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry Potter,magic”,”description”:”Das grosse Abenteuer beginnt, als der Feuerkelch Harry Potters Namen freigibt und Harry damit Teilne …”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2005-11-18″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0304141/&#8221;,”label”:”Harry Potter und der Gefangene von Askaban”,”videoinfo”:{“id”:”humvideo:0304141″,”title”:”Harry Potter und der Gefangene von Askaban”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry Potter,magic”,”description”:”Wahrend die abscheuliche Tante Magda uber den Nachthimmel schwebt, kehrt Harry nach Hogwarts zuruck, …”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2003-06-04″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0295297/&#8221;,”label”:”Harry Potter und die Kammer Desschreckens”,”videoinfo”:{“id”:”humvideo:0295297″,”title”:”Harry Potter und die Kammer Desschreckens”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry Potter,magic”,”description”:”Fliegende Autos, gemeingefahrliche Baume und die Warnung eines mysteriosen Hauselfen – so beginnt fu …”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2002-11-15″}},{“type”:”HumVideoMovingImage”,”location”:”http://hummedia.byu.edu/watch/humvideo:0241527/&#8221;,”label”:”Harry Potter und der Stein der Weisen”,”videoinfo”:{“id”:”humvideo:0241527″,”title”:”Harry Potter und der Stein der Weisen”,”height”:480,”coverage”:”BYU”,”status”:”allowed”,”subject”:”Harry Potter,magic”,”description”:”In der zauberhaften Verfilmung J.K. Rowlings Weltbestseller erfahrt Harry Potter an seinem 11. Gebur …”,”width”:716,”rights”:”shared”,”language”:[“de”],”runningtime”:7200,”date”:”2001-11-16″}}] of type org.json.JSONArray cannot be converted to JSONObject
11-14 10:03:02.732: W/System.err(622): at org.json.JSON.typeMismatch(JSON.java:111)
11-14 10:03:02.752: W/System.err(622): at org.json.JSONObject.(JSONObject.java:158)
11-14 10:03:02.762: W/System.err(622): at org.json.JSONObject.(JSONObject.java:171)
11-14 10:03:02.822: W/System.err(622): at de.vogella.android.asynctask.ReadWebpageAsyncTask$DownloadWebPageTask.doInBackground(ReadWebpageAsyncTask.java:56)
11-14 10:03:02.842: W/System.err(622): at de.vogella.android.asynctask.ReadWebpageAsyncTask$DownloadWebPageTask.doInBackground(ReadWebpageAsyncTask.java:1)
11-14 10:03:02.852: W/System.err(622): at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-14 10:03:02.872: W/System.err(622): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-14 10:03:02.892: W/System.err(622): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-14 10:03:02.902: W/System.err(622): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
11-14 10:03:02.912: W/System.err(622): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-14 10:03:02.922: W/System.err(622): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-14 10:03:02.942: W/System.err(622): at java.lang.Thread.run(Thread.java:856)

thank you.

  • 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-26T20:48:24+00:00Added an answer on May 26, 2026 at 8:48 pm

    You simple have to use below code

    import org.json.JSONObject;
    
    JSONObject jObject = new JSONObject(response);
    

    For rest you can process in the same way

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to get a json response from google's geocoding service. I'm using
I am trying to get a JSON response from our server and the response
I am trying following, 1. Get response using Ajax from the users selection which
I'm trying to get a response from a ASP.NET webservice without using the get
I was trying to parse response data from web server. I am using Xcode
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,
I get the following message back when trying to retrieve a file using TCPClient
I am trying to connect to a server from my app using the following
I'm trying to call a RESTful web service from an Android application using the

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.