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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:29:56+00:00 2026-05-24T12:29:56+00:00

I have the following JSON text to parse in Java: { items: [ {

  • 0

I have the following JSON text to parse in Java:

{
    "items": [
        {
            "key": "D033222DF44E5308482578EB0017588A",
            "Date": "Aug 13 2011",
            "Time": "04:54:46 PM",
            "Company": "CHINA ESSENCE GROUP LTD.",
            "AnnTitle": "FIRST QUARTER RESULTS * FINANCIAL STATEMENT AND RELATED ANNOUNCEMENT",
            "Siblings": "18",
            "SNo": 18
        },
        {
            "key": "C9906046C7F0E232482578EB0030C437",
            "Date": "Aug 13 2011",
            "Time": "04:52:12 PM",
            "Company": "DESIGjsonN STUDIO FURNITURE MFRLTD",
            "AnnTitle": "NOTICE OF BOOK CLOSURE DATE FOR DIVIDEND",
            "Siblings": "18",
            "SNo": 17
        }
    ]
}

Below is my JSONParser class:

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class JSONParser {

private String input = null;

public JSONParser() {
}

public JSONParser(String input) {
    setInput(input);
}

public JSONArray parse() throws JSONException {
    JSONObject obj = new JSONObject();
    return obj.getJSONArray("items");
}

/**
 * @return the input
 */
public String getInput() {
    return input;
}

/**
 * @param input the input to set
 */
public void setInput(String input) {
    this.input = input;
}
}

My main() method class contains these codes to execute the parser to parse the “jsonStr” object:

        JSONParser parser = new JSONParser(jsonStr);
        JSONArray array = parser.parse();
        for (int i = 0; i < array.length(); i++) {
            Object obj = array.get(i);
            System.out.println(">> " + obj.toString() + "\n");
        }

My output shows:

SEVERE: null
org.json.JSONException: JSONObject["items"] not found.

I am using the json.org provided Java codes for JSON.

How should I parse the above string ?

Thanks.

  • 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-24T12:29:57+00:00Added an answer on May 24, 2026 at 12:29 pm

    You have not actually passed the input string to the JSON parsing library. The JSONParser#parse() method needs to (somehow) use this.input. Try this:

    public JSONArray parse() throws JSONException
    {
        JSONObject obj = new JSONObject(this.input);
        return obj.getJSONArray("items");
    }
    

    That said, org.json.JSONObject is an ancient implementation. I would strongly encourage you to use a more modern JSON library, such as one of the following:

    • JSON.simple
    • Google GSON
    • Jackson
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.