Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stleary/JSON-java
A reference implementation of a JSON package in Java.
https://github.com/stleary/JSON-java
hackoberfest2023 hacktoberfest java json public-domain
Last synced: about 12 hours ago
JSON representation
A reference implementation of a JSON package in Java.
- Host: GitHub
- URL: https://github.com/stleary/JSON-java
- Owner: stleary
- License: other
- Created: 2010-12-21T17:46:09.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2024-08-07T17:04:52.000Z (3 months ago)
- Last Synced: 2024-10-29T15:34:54.190Z (10 days ago)
- Topics: hackoberfest2023, hacktoberfest, java, json, public-domain
- Language: Java
- Homepage: http://stleary.github.io/JSON-java/index.html
- Size: 2.78 MB
- Stars: 4,525
- Watchers: 240
- Forks: 2,556
- Open Issues: 41
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- my-awesome - stleary/JSON-java - domain pushed_at:2024-08 star:4.5k fork:2.6k A reference implementation of a JSON package in Java. (Java)
- awesome-json - JSON-java - A reference implementation. (Libraries)
- awesome - JSON-java - A reference implementation of a JSON package in Java. (etc)
- awesome - JSON-java - A reference implementation of a JSON package in Java. (etc)
README
![Json-Java logo](https://github.com/stleary/JSON-java/blob/master/images/JsonJava.png?raw=true)
image credit: Ismael Pérez Ortiz
JSON in Java [package org.json]
===============================[![Maven Central](https://img.shields.io/maven-central/v/org.json/json.svg)](https://mvnrepository.com/artifact/org.json/json)
[![Java CI with Maven](https://github.com/stleary/JSON-java/actions/workflows/pipeline.yml/badge.svg)](https://github.com/stleary/JSON-java/actions/workflows/pipeline.yml)
[![CodeQL](https://github.com/stleary/JSON-java/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/stleary/JSON-java/actions/workflows/codeql-analysis.yml)**[Click here if you just want the latest release jar file.](https://search.maven.org/remotecontent?filepath=org/json/json/20240303/json-20240303.jar)**
# Overview
[JSON](http://www.JSON.org/) is a light-weight language-independent data interchange format.
The JSON-Java package is a reference implementation that demonstrates how to parse JSON documents into Java objects and how to generate new JSON documents from the Java classes.
Project goals include:
* Reliable and consistent results
* Adherence to the JSON specification
* Easy to build, use, and include in other projects
* No external dependencies
* Fast execution and low memory footprint
* Maintain backward compatibility
* Designed and tested to use on Java versions 1.6 - 21The files in this package implement JSON encoders and decoders. The package can also convert between JSON and XML, HTTP headers, Cookies, and CDL.
# If you would like to contribute to this project
For more information on contributions, please see [CONTRIBUTING.md](https://github.com/stleary/JSON-java/blob/master/docs/CONTRIBUTING.md)
Bug fixes, code improvements, and unit test coverage changes are welcome! Because this project is currently in the maintenance phase, the kinds of changes that can be accepted are limited. For more information, please read the [FAQ](https://github.com/stleary/JSON-java/wiki/FAQ).
# Build Instructions
The org.json package can be built from the command line, Maven, and Gradle. The unit tests can be executed from Maven, Gradle, or individually in an IDE e.g. Eclipse.
**Building from the command line***Build the class files from the package root directory src/main/java*
```shell
javac org/json/*.java
```*Create the jar file in the current directory*
```shell
jar cf json-java.jar org/json/*.class
```*Compile a program that uses the jar (see example code below)*
```shell
javac -cp .;json-java.jar Test.java (Windows)
javac -cp .:json-java.jar Test.java (Unix Systems)
```*Test file contents*
```java
import org.json.JSONObject;
public class Test {
public static void main(String args[]){
JSONObject jo = new JSONObject("{ \"abc\" : \"def\" }");
System.out.println(jo);
}
}
```*Execute the Test file*
```shell
java -cp .;json-java.jar Test (Windows)
java -cp .:json-java.jar Test (Unix Systems)
```*Expected output*
```json
{"abc":"def"}
```
**Tools to build the package and execute the unit tests**Execute the test suite with Maven:
```shell
mvn clean test
```Execute the test suite with Gradlew:
```shell
gradlew clean build test
```# Notes
For more information, please see [NOTES.md](https://github.com/stleary/JSON-java/blob/master/docs/NOTES.md)
# Files
For more information on files, please see [FILES.md](https://github.com/stleary/JSON-java/blob/master/docs/FILES.md)
# Release history:
For the release history, please see [RELEASES.md](https://github.com/stleary/JSON-java/blob/master/docs/RELEASES.md)