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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:21:44+00:00 2026-06-02T12:21:44+00:00

I have a JSON file with 2 JSON-Arrays in it: One Array for routes

  • 0

I have a JSON file with 2 JSON-Arrays in it:
One Array for routes and one Array for sights.

A route should consist of several sights where the user gets navigated to.
Unfortunately I am getting the error:

JSONException: Value of type java.lang.String cannot be converted to JSONObject

Here are my variables and the code that parses the JSON-File:

private InputStream is = null;
private String json = "";
private JSONObject jObj = null;

try {
    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();
    // hier habe ich das JSON-File als String
    json = sb.toString();
    Log.i("JSON Parser", json);
} catch (Exception e) {
    Log.e("Buffer Error", "Error converting result " + e.toString());
}

// try parse the string to a JSON object
try {
    jObj = new JSONObject(json);
} catch (JSONException e) {
    Log.e("JSON Parser", "Error parsing data " + e.toString());
}

// return JSON String
return jObj;
}

Log.i(“JSON Parser”, json);
shows me that at the beginning of the generated string there is a strange sign: enter image description here

but the error happens here:

try {
    jObj = new JSONObject(json);
} catch (JSONException e) {
    Log.e("JSON Parser", "Error parsing data " + e.toString());
}

04-22 14:01:05.043: E/JSON Parser(5868): Error parsing data
org.json.JSONException: Value //STRANGE SIGN HERE // of type
java.lang.String cannot be converted to JSONObject

anybody has a clue on how to get rid of these signs in order to create the JSONObject?

  • 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-02T12:21:47+00:00Added an answer on June 2, 2026 at 12:21 pm

    see this
    http://stleary.github.io/JSON-java/org/json/JSONObject.html#JSONObject-java.lang.String-

    JSONObject

    public JSONObject(java.lang.String source)
               throws JSONException
    

    Construct a JSONObject from a source JSON text string. This is the most commonly used` JSONObject constructor.

    Parameters:
        source - `A string beginning with { (left brace) and ending with } (right brace).` 
    Throws:
        JSONException - If there is a syntax error in the source string or a duplicated key.
    

    you try to use some thing like:

    new JSONObject("{your string}")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file which contains two JSON arrays; one is holding the column
I have a PHP file that returns a JSON array. I need to extract
I have a PHP file that serves up a JSON array populated from a
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
I have a JSON file that I would like to create an multi-dimensional array
I need to parse data from one JSON file in order to validate arrays,
I have a json file of data and the only item for time i
I have parse json file which contain more than hundred location name, there latitude
I have a JSON file that has more name value pairs than I care
I have a large JSON file that contains A LOT of similar code. It's

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.