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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:49:04+00:00 2026-05-24T03:49:04+00:00

I created a JSON file and I uploaded on a domain, my goal is

  • 0

I created a JSON file and I uploaded on a domain, my goal is to parse that document e get back the informations but I do something wrong, this is my JSON file:

{
    "Show" : {
        "id" : "abcde123",
        "name" : "Traviata",
        "date" : "September 15, 2011"
    }
}

This is the Java code that I use to parse the JSON:

private void parse(){
    try {

        URL eventsJSON = new URL("http://www.site.com/test/sample.json");
        URLConnection tc = eventsJSON.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(tc.getInputStream()));

        String line;
        while ((line = in.readLine()) != null) {
            JSONArray jArray = new JSONArray(line);

            for (int i = 0; i < jArray.length(); i++) {
                eventsJSONObject = (JSONObject) jArray.get(i);

            }
        }

        JSONArray eventsArray = eventsJSONObject.getJSONArray("Show");

    //name of the show
    Log.d("LOG", jArray.getJSONObject(0).getString("name").toString());

    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

But the class isn’t working.. can someone help me please?
Thanks!!!! 🙂

EDIT:
This is a working code, but I can’t make it work parsing the JSON from a file

 String jString = "{\"Show\" : {\"from\" : \"June 12, 2011\",\"id\" : \"abcde123\",\"name\" : \"Traviata\"}}";


 JSONObject jObject = new JSONObject(jString);
 JSONObject eventsObject = jObject.getJSONObject("Shows");

 String eventId = eventsObject.getString("id");
 String eventName = eventsObject.getString("name");
 String eventDateFrom = eventsObject.getString("from");

how do I implement the buffered reader and memorize the JSON code in the jString String?

  • 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-24T03:49:05+00:00Added an answer on May 24, 2026 at 3:49 am

    This:

    JSONArray eventsArray = eventsJSONObject.getJSONArray("Show");
    

    should be parsed as JSONObject:

    JSONObject eventObj = eventsJSONObject.getJSONOnject("Show");
    

    Rest should be simple. “show” represents an object with 3 fields, not an array.

    BTW, an array would look like that:

    {
        "Show" : [
            "id" : "abcde123",
            "name" : "Traviata",
            "date" : "September 15, 2011"
        ]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a php file to return data encoded with JSON and then used
This the model that I want to create using json file Ext.define('Users', { extend:
I want to convert a JSON file I created to a SQLite database. My
python manage.py dumpdata modelName > file.json . created an empty database for a user
I have a dynamically created json file. I want to know only the errors
I have one JSON file like following: {entries:[{title:‘foo’,id:‘01’,created:‘2010-12-06’},{title:‘bar’,id:‘02’,created:‘2010-12-05’}]} And also I have one html
I am testing out some code and I have created a json file with
I created an ASMX file with a code behind file. It's working fine, but
I have a JSON file that will create my ParentModel as well as populate
I'm using google maps v3. I created some markers, with info from json file.

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.