D3lph1 / JSONic

JSON in Java is convenient!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JSONic

JSON in Java is convenient!

What is JSONic?

JSONic - is a open-sourced Java library for convenient work with json. It allows you to convert a JSON string to program objects and vice versa. You can format the output json the way you want, for example, to make it easy for a person to read it.

Overview

Deserialize JSON:

Jsonic jsonic = new Jsonic();

// {
//     "java": {
//         "json": "convenient"
//     }   
// }
JsonObject obj = jsonic.fromJson(json).getAsObject();
// convenient
String result = obj.get("java").getAsObject().get("json").getAsPrimitive().getAsString();

Serialize JSON:

class Response
{
    public int code;
    
    public String status;
    
    @Serialize(false)
    public String secret;
}

// ...

Response response = new Response();
response.code = 0;
response.status = "success";
response.secret = "This string will not be serialized";
Jsonic jsonic = new Jonic(new JsonBuilder(BuilderOptions.PRETTY));

// {
//     "code": 0,
//     "status": "success"
// }
String json = jsonic.toJson(response);

Documentation

Read on GitHub wiki

License

The JSONic is open-sourced software licensed under the MIT license.

About

JSON in Java is convenient!

License:MIT License


Languages

Language:Java 100.0%