Java libraries for serializing, deserializing, and manipulating JSON values

Overview

java-json-toolkit

The json-toolkit repository contains the code to the following libraries:

  • json-toolkit-text: basic library for conversion between textual representations and special Java classes
  • json-toolkit-java (available soon)

json-toolkit-text

The json-toolkit-text library can be used to convert textual representations of JSON values into Java objects and to convert those Java objects into textual representations. The conversion into the textual version can use a configurable formatter to create texts that are more easy to read by humans.

Installation

To use the library in your projects, you have to create the dependency to the library.

Gradle:

dependencies {
  implementation 'de.d-coding:json-toolkit-text:1.0.2'
}

Maven:

<dependency>
  <groupId>de.d-coding</groupId>
  <artifactId>json-toolkit-text</artifactId>
  <version>1.0.2</version>
</dependency>

Usage

Sample usage code snippets.

Parsing JSON texts:

String jsonText = "{\"foo\":{}}";
JSONLLParser parser = new JSONLLParser();
JSONValue jsonValue = parser.parse(stringValue);

or

JSONObject object = JSON.decode("{\"foo\":{}}");

or

JSONArray array = JSON.decode("[1, 2, null, 3]");

Manipulating JSON values:

JSONValue jsonValue = new JSONObject();
jsonValue.put("foo", "bar");

or

JSONValue jsonValue = JSON.decode("{\"foo\":{}}");
JSONObject object = (JSONObject)jsonValue.get("foo");
object.put("bar", 42);

or

JSONValue jsonValue = JSON.decode("{\"foo\":{}}");
jsonValue.<JSONObject>getAs("foo").put("bar", 42);

Convert to unformatted text:

JSONValue jsonValue = new JSONObject();
jsonValue.put("foo", "bar");
String text = jsonValue.toString();

Convert to formatted text:

JSONValue jsonValue = new JSONObject();
jsonValue.put("foo", "bar");
JSONFormatter formatter = new JSONFormatter();
String text = formatter.toString(jsonValue);

or

JSONValue jsonValue = new JSONObject();
jsonValue.put("foo", "bar");
JSON.encode(jsonValue);

Convert to formatted text with indention of 3 spaces:

JSONValue jsonValue = new JSONObject();
jsonValue.put("foo", "bar");
JSONFormatter formatter = new JSONFormatter();
JSONFormatterSettings settings = formatter.getSettings();
settings.setIndentionString("   ");
String text = formatter.toString(jsonValue);

License

json-toolkit is released under the Apache 2.0 license.

Copyright (C) 2022 d-coding GmbH

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
You might also like...

A JSON Schema validation implementation in pure Java, which aims for correctness and performance, in that order

Read me first The current version of this project is licensed under both LGPLv3 (or later) and ASL 2.0. The old version (2.0.x) was licensed under LGP

Jan 4, 2023

Screaming fast JSON parsing and serialization library for Android.

Screaming fast JSON parsing and serialization library for Android.

#LoganSquare The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consiste

Dec 18, 2022

JSON query and transformation language

JSLT JSLT is a complete query and transformation language for JSON. The language design is inspired by jq, XPath, and XQuery. JSLT can be used as: a q

Dec 30, 2022

Framework for serialization to Json, XML, Byte and Excel, therefore an oviparous wool milk sow J

Framework for serialization to Json, XML, Byte and Excel, therefore an oviparous wool milk sow J

NetworkParser Framework for serialization from Java objects to Json, XML and Byte. NetworkParser is a simple framework for serializing complex model s

Nov 18, 2020

A query language for JSON and a template engine to generate text output.

Josson & Jossons Josson is a query language for JSON. Jossons is a template engine to generate text output. Features and Capabilities of Josson Query

Dec 14, 2022

A fast JSON parser/generator for Java.

A fast JSON parser/generator for Java.

fastjson Fastjson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON str

Dec 31, 2022

Sawmill is a JSON transformation Java library

Sawmill is a JSON transformation Java library

Update: June 25, 2020 The 2.0 release of Sawmill introduces a breaking change to the GeoIpProcessor to comply with the updated license of the MaxMind

Jan 1, 2023

Genson a fast & modular Java Json library

Genson Genson is a complete json - java conversion library, providing full databinding, streaming and much more. Gensons main strengths? Easy to use

Jan 3, 2023

A reference implementation of a JSON package in Java.

JSON in Java [package org.json] Click here if you just want the latest release jar file. Overview JSON is a light-weight language-independent data int

Jan 6, 2023
Releases(v1.0.4)
Owner
d-coding GmbH
d-coding GmbH
MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJO to JSON in a declarative way.

MapNeat is a JVM library written in Kotlin that provides an easy to use DSL (Domain Specific Language) for transforming JSON to JSON, XML to JSON, POJ

Andrei Ciobanu 59 Sep 17, 2022
Generate Java types from JSON or JSON Schema and annotates those types for data-binding with Jackson, Gson, etc

jsonschema2pojo jsonschema2pojo generates Java types from JSON Schema (or example JSON) and can annotate those types for data-binding with Jackson 2.x

Joe Littlejohn 5.9k Jan 5, 2023
A simple java JSON deserializer that can convert a JSON into a java object in an easy way

JSavON A simple java JSON deserializer that can convert a JSON into a java object in an easy way. This library also provide a strong object convertion

null 0 Mar 18, 2022
JSON to JSON transformation library written in Java.

Jolt JSON to JSON transformation library written in Java where the "specification" for the transform is itself a JSON document. Useful For Transformin

Bazaarvoice 1.3k Dec 30, 2022
Essential-json - JSON without fuss

Essential JSON Essential JSON Rationale Description Usage Inclusion in your project Parsing JSON Rendering JSON Building JSON Converting to JSON Refer

Claude Brisson 1 Nov 9, 2021
A 250 lines single-source-file hackable JSON deserializer for the JVM. Reinventing the JSON wheel.

JSON Wheel Have you ever written scripts in Java 11+ and needed to operate on some JSON string? Have you ever needed to extract just that one deeply-n

Roman Böhm 14 Jan 4, 2023
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 8, 2023
A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back

A universal types-preserving Java serialization library that can convert arbitrary Java Objects into JSON and back, with a transparent support of any kind of self-references and with a full Java 9 compatibility.

Andrey Mogilev 9 Dec 30, 2021
A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

?? 零代码、热更新、全自动 ORM 库,后端接口和文档零代码,前端(客户端) 定制返回 JSON 的数据和结构。 ?? A JSON Transmission Protocol and an ORM Library for automatically providing APIs and Docs.

Tencent 14.4k Dec 31, 2022
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 8.7k Dec 31, 2022