Skip to content

Persist in JSON format

xcesco edited this page Jan 19, 2017 · 4 revisions

JSON format

The annotation @BindType allow to persist the class User

@BindType
public class User {
  public String email;
  public String name;
  public String surname;
}

For default, @BindType annotation will bind all public fields and attribute with getter/setter. JSON persistence context is the only available context for default, so you does not need to registry it.

Code to generate an JSON version of User instance class:

BinderContext binderContext=KriptonBinder.jsonBind();
String result = binderContext.serialize(bean);

Generated JSON will be similar to:

{
    "email": "[email protected]",
    "name": "Tonj",
    "surname": "Manero",
    "username": "1234
}

Kripton does not support (in current release) pretty printing, so output will be a inline JSON. I format JSON for readability reason.

Code to parse JSON and create a User instance:

User user=binderContext.parse(result, User.class);

Table of Contents

Query definition

Features

Relations

Multithread supports

Modularization

Annotations for data convertion

Annotations for SQLite ORM

Annotations for shared preferences

Clone this wiki locally