Json Easy

Lightweight and simple json api write in pure java without any dependencies.

License

License

Categories

Categories

JSON Data
GroupId

GroupId

fr.bigray
ArtifactId

ArtifactId

json-easy
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

Json Easy
Lightweight and simple json api write in pure java without any dependencies.
Project URL

Project URL

https://github.com/Big-Ray/json-easy
Source Code Management

Source Code Management

https://github.com/Big-Ray/json-easy/tree/master

Download json-easy

How to add to project

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

Dependencies

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.2.0

Project Modules

There are no modules declared in this project.

Json-Easy

Build status: build_status Coverage status : codecov

Json-Easy has for vocation to be most simple to create, parse and manipulate Json with Java.

Json-Easy is written in pure Java without any others dependencies to be lightweight as possible.

Getting Started

Create a JsonObject

JsonObject jsObjectChild = JsonObject.createObject()
	.$( "key1", "value1" )
	.$( "key2", "value2" );

JsonObject jsObject = JsonObject.createObject()
    .$( "key1", "value1" )
    .$( "key2", "value2" )
    .$( "key3", 1 )
    .$( "key4", 123.45 )
    .$$( jsObjectChild )
    .$( "key5", JsonObject.createObject()
        .$( "key1", "value1" )
        .$( "key2", "value2" )
        .$( "key3", JsonArray.createArray()
            .$( "value1" )
            .$( "value2" )
            .$( 3 )
            .$( JsonObject.createObject()
                .$( "key1", "value1" )
            )
        ))
    ))
);

Create a JsonArray

JsonArray jsArrayChild = JsonArray.createArray()
	.$( "value1" )
	.$( 12345 )
	.$( 1L );

JsonArray jsArray = JsonArray.createArray()
    .$( "value1" )
    .$( "value2" )
    .$( 1 )
    .$( 123.45 )
    .$$( jsArrayChild )
    .$( JsonObject.createObject()
        .$( "key1", "value1" )
        .$( "key2", "value2" )
        .$( "key3", JsonArray.createArray()
            .$( "value1" )
            .$( "value2" )
            .$( 3 )
            .$( JsonObject.createObject()
                .$( "key1", "value1" )
            )
        ))
    ))
);

JsonValue to json string

JsonObject jsObject = JsonObject.createObject()
    .$( "key1", "value1" )
    .$( "key2", "value2" )
);
String json = JsObject.toJson();

// Ouput {"key1":"value1", "key2":"value2"}

JsonValue from json string

JsonValue jsValue = JsonParser.parse( "{\"key1\":\"value1\"}" );
JsonObject jsObject = jsonValue.as(JsonObject.class);

// Other way
JsonArray jsArray = JsonArray.fromJson( "[\"value1\", 1234]" );

JsonObject and JsonArray manipulation

JsonObject and JsonArray classes extends respectively LinkedHashMap<String, JsonValue> and ArrayList<JsonValue>, so, if you known how to manipule these Collections, you known to manipulate JsonObject and JsonArray.

License

This project is licensed under the Apache-2.0 License - see the LICENSE file for details.

Built With

  • Maven - Dependency Management

Author

  • Raynald BUQUET - Big-Ray

Versions

Version
1.1.1