https://github.com/theelectronwill/json-javalib
Fast and simple JSON library for Java
https://github.com/theelectronwill/json-javalib
java java-library json
Last synced: 2 months ago
JSON representation
Fast and simple JSON library for Java
- Host: GitHub
- URL: https://github.com/theelectronwill/json-javalib
- Owner: TheElectronWill
- License: mit
- Created: 2016-03-22T14:10:20.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-06-25T12:19:36.000Z (about 10 years ago)
- Last Synced: 2025-10-09T06:35:05.967Z (9 months ago)
- Topics: java, java-library, json
- Language: Java
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# JSON-javalib
This is a fast and simple [JSON](json.org) library for Java.
## How to use
The important class is Toml.java. It contains public static methods for reading and writing JSON data.
You can read data like this:
```java
//import com.electronwill.json.Json
File file = new File("myFile.json");
FileReader reader = new FileReader(file);
Map jsonObject = Json.readObject(reader);
```
And write data like this:
```java
//import com.electronwill.json.Json
File file = new File("myFile.json");
FileWriter writer = new FileWriter(file);
Map jsonObject = ...//put your data here
boolean humanFriendly = true;//true to indent and space the output, false to compact it
Json.write(jsonObject, writer, humanFriendly);
```
You can also use `JsonReader` and `JsonWriter` directly.
## Data types
The JSON data is mapped to the following java types:
JSON | Java
------- | -------
Integer | `int` or `long` (it depends on the size)
Decimal | `double`
Boolean | `boolean`
String | `String`
Array | `List`
Object | `Map`
null | `null`
## Java version
This library requires Java 7.