A simple library for working with JSON Objects. This is based on Clifton Labs' version (https://github.com/cliftonlabs/json-simple), which is a fork of Yidong Fang's version (https://github.com/fangyidong/json-simple).
You can obtain a copy of SimpleJSON via the following methods:
- Download a pre-built copy from the Releases page. The latest version is release 1.2.0.
- Build from source (see below).
- Include it as a dependency in your project (see the Development API section).
SimpleJSON uses Apache Maven to build and handle dependencies.
- Java Development Kit (JDK) 8 or higher
- Git
- Apache Maven
Run the following commands to build the library .jar
file:
git clone https://github.com/bspfsystems/SimpleJSON.git
cd SimpleJSON/
mvn clean install
The .jar
file will be located in the target/
folder.
To add SimpleJSON as a dependency to your project, use one of the following common methods (you may use others that exist, these are the common ones):
Maven:
Include the following in your pom.xml
file:
<repositories>
<repository>
<id>sonatype-repo</id>
<url>https://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bspfsystems</groupId>
<artifactId>simple-json</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Gradle:
Include the following in your build.gradle
file:
repositories {
maven {
url "https://oss.sonatype.org/content/repositories/releases/"
}
}
dependencies {
implementation "org.bspfsystems:simple-json:1.2.0"
}
These are some basic usages of SimpleJSON; for a full scope of what the library offers, please see the Javadocs section below.
// A fair number of serialization and deserialization methods throw a JSONException
try {
// Deserialize a file into a JSONObject
JSONObject object = JSONParser.deserialize(new FileReader(new File("data.json")));
// Add a few items to the object
object.set("new_id", UUID.randomUUID().toString());
object.set("new_number", (new Random()).nextInt());
// Get a formatted String to print out to a file (with proper indents and newlines)
String formatted = JSONParser.format(JSONParser.serialize(object));
} catch (JSONException e) {
e.printStackTrace();
}
The API Javadocs can be found here, kindly hosted by javadoc.io.
Please check out CONTRIBUTING.md for more information.
SimpleJSON uses the following licenses:
Contributions to the project will remain licensed under the respective license, as defined by the particular license. Copyright/ownership of the contributions shall be governed by the license. The use of an open source license in the hopes that contributions to the project will have better clarity on legal rights of those contributions.
Please Note: This is not legal advice. If you are unsure on what your rights are, please consult a lawyer.