Fast JSON

A fast JSON library written in Java

Лицензия

Лицензия

Категории

Категории

JSON Данные
Группа

Группа

me.joshlarson
Идентификатор

Идентификатор

fast-json
Последняя версия

Последняя версия

3.0.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Fast JSON
A fast JSON library written in Java
Ссылка на сайт

Ссылка на сайт

https://github.com/Josh-Larson/fast-json
Система контроля версий

Система контроля версий

https://github.com/Josh-Larson/fast-json

Скачать fast-json

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/me.joshlarson/fast-json/ -->
<dependency>
    <groupId>me.joshlarson</groupId>
    <artifactId>fast-json</artifactId>
    <version>3.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/me.joshlarson/fast-json/
implementation 'me.joshlarson:fast-json:3.0.1'
// https://jarcasting.com/artifacts/me.joshlarson/fast-json/
implementation ("me.joshlarson:fast-json:3.0.1")
'me.joshlarson:fast-json:jar:3.0.1'
<dependency org="me.joshlarson" name="fast-json" rev="3.0.1">
  <artifact name="fast-json" type="jar" />
</dependency>
@Grapes(
@Grab(group='me.joshlarson', module='fast-json', version='3.0.1')
)
libraryDependencies += "me.joshlarson" % "fast-json" % "3.0.1"
[me.joshlarson/fast-json "3.0.1"]

Зависимости

runtime (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

How to use it:

Download

Read:

To read, there are several options. First is using the convenience class JSON:

String json = "...";
JSONObject obj = JSON.readObject(json, true); // Second argument is whether or not to print errors

Second is using a string:

String json = "...";
JSONObject obj;
try (JSONInputStream in = new JSONInputStream(json)) {
	obj = in.readObject();
} catch (IOException | JSONException e) {
	e.printStackTrace();
}

Third is using an input stream, such as a file:

JSONObject obj;
try (JSONInputStream in = new JSONInputStream(new FileInputStream(new File("myjson.txt")))) {
	obj = in.readObject();
} catch (IOException | JSONException e) {
	e.printStackTrace();
}

Write:

For write, there are two options. First is using the toString() function:

JSONObject obj = new JSONObject();
obj.put("myint", 5);
System.out.println(obj.toString());

Behind the scenes, it creates a new byte array output stream and uses the following method to create the string. Second option is using an output stream:

JSONObject obj = new JSONObject();
obj.put("myint", 5);
try (JSONOutputStream out = new JSONOutputStream(new FileOutputStream(new File("myjson.txt")))) {
	out.writeObject(obj);
} catch (IOException e) {
	e.printStackTrace();
}

Additional Note(s):

  • There is both a JSONObject and an JSONArray, both are compatible with the input and output streams.
  • The class JSON will automatically clean up stream resources

Версии библиотеки

Версия
3.0.1
1.7