https://github.com/big-ray/json-easy
Json easy in java
https://github.com/big-ray/json-easy
java-8 json json-api
Last synced: 4 months ago
JSON representation
Json easy in java
- Host: GitHub
- URL: https://github.com/big-ray/json-easy
- Owner: Big-Ray
- License: apache-2.0
- Created: 2018-05-06T20:11:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-15T07:37:50.000Z (almost 7 years ago)
- Last Synced: 2023-05-25T13:06:10.163Z (about 2 years ago)
- Topics: java-8, json, json-api
- Language: Java
- Size: 38.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Json-Easy
Build status: [](https://travis-ci.org/Big-Ray/json-easy)
Coverage status : [](https://codecov.io/gh/Big-Ray/json-easy)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```java
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
```java
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
```java
JsonObject jsObject = JsonObject.createObject()
.$( "key1", "value1" )
.$( "key2", "value2" )
);
String json = JsObject.toJson();// Ouput {"key1":"value1", "key2":"value2"}
```## JsonValue from json string
```java
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\ and ArrayList\, 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](LICENSE) file for details.
### Built With
* [Maven](https://maven.apache.org/) - Dependency Management
### Author
* **Raynald BUQUET** - *Big-Ray*