Skip to content

Persist in JSON format

xcesco edited this page Jan 24, 2017 · 4 revisions

JSON format

The annotation @BindType allows to persist a class instance.

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

As default, @BindType annotation 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": "dummy@test.org",
    "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