Download the ZIP file from this URL and extract it to get the Jar. Add the Jar to your build path. To check the available classes in this Jar use this URL.

To Add this Jar to your build path Right click the Project > Build Path > Configure build path> Select Libraries tab > Click Add External Libraries > Select the Jar file Download

I hope this will solve your problem

Answer from Ramkumar Murugadoss on Stack Overflow
🌐
Oracle
docs.oracle.com › javaee › 7 › api › javax › json › JsonArray.html
JsonArray (Java(TM) EE 7 Specification APIs)
A JsonArray object can be created by reading JSON data from an input source or it can be built from scratch using an array builder object.
🌐
GitHub
github.com › stleary › JSON-java › blob › master › src › main › java › org › json › JSONArray.java
JSON-java/src/main/java/org/json/JSONArray.java at master · stleary/JSON-java
import java.util.Map; · · /** * A JSONArray is an ordered sequence of values. Its external text form is a · * string wrapped in square brackets with commas separating the values. The · * internal form is an object having <code>get</code> and <code>opt</code> * methods for accessing the values by index, and <code>put</code> methods for ·
Author   stleary
🌐
TutorialsPoint
tutorialspoint.com › org_json › org_json_jsonarray.htm
Org.Json - HTTP Class
JSONArray: ["Apple","Banana","Orange","Mango","Guava"] package com.tutorialspoint; import org.json.JSONArray; public class JsonDemo { public static void main(String[] args) { JSONArray list = new JSONArray(); list.put(Integer.valueOf(100)); list.put(Integer.valueOf(200)); list.put(Integer.valueOf(300)); list.put(Integer.valueOf(400)); list.put(Integer.valueOf(500)); System.out.println("JSONArray: "); System.out.println(list); } }
🌐
Javadoc.io
javadoc.io › doc › org.json › json › 20171018 › org › json › JSONArray.html
JSONArray (JSON in Java 20171018 API)
https://javadoc.io/doc/org.json/json · Current version 20171018 · https://javadoc.io/doc/org.json/json/20171018 · package-list path (used for javadoc generation -link option) https://javadoc.io/doc/org.json/json/20171018/package-list ·
🌐
Stleary
stleary.github.io › JSON-java › org › json › JSONArray.html
JSONArray
The internal form is an object ... values. The values can be any of these types: Boolean, JSONArray, JSONObject, Number, String, or the JSONObject.NULL object. The constructor can convert a JSON text into a Java object....
🌐
TutorialsPoint
tutorialspoint.com › how-to-write-create-a-json-array-using-java
How to Write/create a JSON array using Java?
import java.io.FileWriter; import java.io.IOException; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class WritingJSONArray { public static void main(String args[]) { //Creating a JSONObject object JSONObject jsonObject = new JSONObject(); //Inserting key-value pairs into the json object jsonObject.put("ID", "1"); jsonObject.put("First_Name", "Krishna Kasyap"); jsonObject.put("Last_Name", "Bhagavatula"); jsonObject.put("Date_Of_Birth", "1989-09-26"); jsonObject.put("Place_Of_Birth", "Vishakhapatnam"); jsonObject.put("Country", "25000"); //Creating a json array JSO
Top answer
1 of 3
3

With the below code it is working perfect for me. Can you check whether the specified file location is correct? Also try reading id like pagesObject.get("id")

package json.simple;

import java.io.FileReader;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

public class ReadJSON {
    public static void main(String[] args) throws Exception {
        JSONParser parser = new JSONParser();
        JSONObject pagesObject = (JSONObject) parser.parse(new FileReader("/home/user/tmp/test.json"));
        System.out.println(pagesObject.get("id"));
        System.out.println(pagesObject.get("pages").getClass().getName());
        JSONArray jsonArray= (JSONArray) pagesObject.get("pages");

        for(int i=0; i<jsonArray.size(); i++){
            System.out.println(jsonArray.get(i));
        }
    }
}

And here is the content of my test.json. Exactly same as yours

{
    "id": "0912898213",
    "pages": [
        {
            "pageUrl": "http://www.example0.com",
            "results": [
                {
                    "number": "1"
                },
                {
                    "number": "2"
                }
            ]
        },
        {
            "pageUrl": "http://www.example1.com",
            "results": [
                {
                    "number": "3"
                },
                {
                    "number": "4"
                }
            ]
        }
    ]
}

And here is my dependency in maven

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <version>1.1.1</version>
</dependency>
2 of 3
1

Finally its working now, but I still do not know the actual cause of the problem. I partitioned the file into two separate json files, and executed the code on both of them and it worked. Now I just have to merge them and its done! Not a good solution but couldn't find another way!

Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 27266675 › how-to-import-jsonarray-to-arraylist
java - How to import JSONArray to ArrayList ? - Stack Overflow
You can't just "import" json data, but you can parse it: stackoverflow.com/questions/2591098/how-to-parse-json-in-java · – Anton Kolyaev Dec 3, 2014 at 8:46 · Add a comment | Related questions · 3 · JSONObject to ArrayList? 1 · Putting a JSONArray into a list(Android) 3 ·
🌐
TutorialsPoint
tutorialspoint.com › how-to-read-parse-json-array-using-java
How to read/parse JSON array using Java?
Iterator<String> iterator = jsonArray.iterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); } Below is an example of a Java program that parses the above-created sample.json file, reads its contents, and displays them. import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.Iterator; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; public class ReadingArrayFromJSON { public static void main(String args[]) { //Cr
🌐
Java Code Geeks
javacodegeeks.com › home › core java
Converting a JSON Object to a JSON Array in Java - Java Code Geeks
August 1, 2025 - // JsonConversionExample.java import org.json.JSONArray; import org.json.JSONObject; public class JsonConversionExample { public static void main(String[] args) { String jsonString = "{ \"apple\": 1, \"banana\": 2, \"cherry\": 3 }"; JSONObject jsonObject = new JSONObject(jsonString); JSONArray jsonArray = new JSONArray(jsonObject.toMap().values()); System.out.println("Converted JSON Array:"); System.out.println(jsonArray.toString(2)); } }
🌐
Android Developers
developer.android.com › api reference › jsonarray
JSONArray | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Adambien
adambien.blog › roller › abien › entry › java_16_converting_a_json
Converting a JSON array to Java types with Pattern Matching
import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonNumber; import javax.json.JsonString; import javax.json.JsonValue; JsonArray load() { var jsonArray = """ ["hello,duke",42] """; return Json.createReader(new StringReader(jsonArray)).readArray(); } ...can be converted to Java data types with the Java 16+ (JEP 394: Pattern Matching for instanceof) without any casting:
🌐
Linus Tech Tips
linustechtips.com › software › programming
How to import JSON simple package into Java? (Only using VSCode, not Maven/other IDEs) - Programming - Linus Tech Tips
September 3, 2022 - I need it so that the import code works and I can actually use it in my project. JSON jar image: Import code: import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.js...
🌐
GeeksforGeeks
geeksforgeeks.org › java › what-is-json-java-org-json
What is JSON-Java (org.json)? - GeeksforGeeks
July 17, 2022 - Java · // importing JSON simple libraries import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; // Creating a public class public class ...
🌐
Reddit
reddit.com › r/javahelp › import org.json.simple.jsonarray; how do i resolve this error? (java newbie)
r/javahelp on Reddit: import org.json.simple.JSONArray; how do I resolve this error? (java newbie)
January 24, 2022 -

I have tried downloading this and adding it to my project on eclipse as an external file yet an error keeps showing up?

http://www.java2s.com/Code/Jar/j/Downloadjavajsonjar.htm

Top answer
1 of 4
3
an error keeps showing up? Try to be a bit more specific when asking for help. What is the error?
2 of 4
1
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://imgur.com/a/fgoFFis ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
🌐
Coderanch
coderanch.com › t › 694185 › open-source › reading-JSON-array
Help reading JSON array [Solved] (Open Source Projects forum at Coderanch)
The following code reads the "Control" JSON element okay, but gets the following error when reading the Zones array element (the error occurs at the last code line): java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to [[Ljava.lang.Integer; I have tried this with both Zones[] ...
🌐
Javadoc.io
javadoc.io › doc › com.google.code.gson › gson › 2.6.2 › com › google › gson › JsonArray.html
JsonArray - gson 2.6.2 javadoc
Bookmarks · Latest version of com.google.code.gson:gson · https://javadoc.io/doc/com.google.code.gson/gson · Current version 2.6.2 · https://javadoc.io/doc/com.google.code.gson/gson/2.6.2 · package-list path (used for javadoc generation -link option) · https://javadoc.io/doc/com.goog...
🌐
SourceForge
json-lib.sourceforge.net › apidocs › net › sf › json › JSONArray.html
JSONArray (Overview (json-lib jdk 1.3 API))
The internal form is an object ... values. The values can be any of these types: Boolean, JSONArray, JSONObject, Number, String, or the JSONNull object. The constructor can convert a JSON text into a Java object....