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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:29:01+00:00 2026-06-11T23:29:01+00:00

Hi i am getting this JsonException sometimes… why this happen can any body solve

  • 0

Hi i am getting this JsonException sometimes… why this happen can any body solve this problem below is my code.

  public int getResult(String name, double lat, double lon) {
        try {
            HttpClient httpclient = new DefaultHttpClient();
            String query = URLEncoder.encode(name, "utf-8");

            HttpPost httppost = new HttpPost("http://00004rl.rcomhost.com/demo/?json=get_dealing&dev=1&store_name=" + query + "&longitude=" + lon
                    + "&latitude=" + lat);
            JSONObject object = new JSONObject();
            StringEntity se = new StringEntity(object.toString());
            se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
            httppost.setEntity(se);
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            InputStream is = entity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            JSONObject jso = new JSONObject(sb.toString());
            if (jso.getString("status").equals("ok")) {
                return 1;
            }
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
        return 0;
    }

i am getting below exception which is some time my logcat is below

   09-25 19:13:26.079: W/System.err(4842): org.json.JSONException: Value <!DOCTYPE of type java.lang.String cannot be converted to JSONObject
   09-25 19:13:26.079: W/System.err(4842):  at org.json.JSON.typeMismatch(JSON.java:107)
   09-25 19:13:26.079: W/System.err(4842):  at org.json.JSONObject.<init>(JSONObject.java:158)
   09-25 19:13:26.079: W/System.err(4842):  at org.json.JSONObject.<init>(JSONObject.java:171)
   09-25 19:13:26.079: W/System.err(4842):  at com.eheuristics.android.diegodeals.googleplacesandmaps.MainActivity$LoadPlaces.getResult(MainActivity.java:246)
   09-25 19:13:26.079: W/System.err(4842):  at com.eheuristics.android.diegodeals.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:208)
   09-25 19:13:26.079: W/System.err(4842):  at com.eheuristics.android.diegodeals.googleplacesandmaps.MainActivity$LoadPlaces.doInBackground(MainActivity.java:1)
   09-25 19:13:26.079: W/System.err(4842):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
   09-25 19:13:26.079: W/System.err(4842):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
  09-25 19:13:26.089: W/System.err(4842):   at java.util.concurrent.FutureTask.run(FutureTask.java:138)
   09-25 19:13:26.089: W/System.err(4842):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
   09-25 19:13:26.089: W/System.err(4842):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
  09-25 19:13:26.089: W/System.err(4842):   at java.lang.Thread.run(Thread.java:1019)
  • 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-11T23:29:02+00:00Added an answer on June 11, 2026 at 11:29 pm

    Your server sends you responses in html sometimes, not json.

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

Sidebar

Related Questions

Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
I am getting a NullPointerException becauase of this LogCat message: 02-17 13:01:10.766: W/System.err(950): org.json.JSONException:
I am getting the following error in my code: System.JSONException null Don't know the
I'm getting a json exception when I try to run my code. The problem
Getting this error while compiling C++ code: undefined reference to `__stack_chk_fail' Options already tried:
I am getting this Logcat: 08-14 11:42:55.923: W/System.err(1137): org.json.JSONException: Value {error:0,success:0,tag:helloworld} of type org.json.JSONObject
I have a problem with this code. This is a tutorial code that show
Can someone please tell my why I'm getting a null pointer exception with this
Getting this out of the way; I don't frequently do much in php or
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler

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.