AutoJson

Additional

Language
Java
Version
1.0.3 (Feb 20, 2016)
Created
Jul 11, 2015
Updated
Dec 22, 2018 (Retired)
Owner
Andrew Chen (yongjhih)
Contributors
Tobias Preuss (johnjohndoe)
Felipe Lima (felipecsl)
Francesco Sardo (frankiesardo)
Sebastiano Poggi (rock3r)
Wendly
Andrew Chen (yongjhih)
The Gitter Badger (gitter-badger)
York Tsai (ynntk4815)
Imran (imran0101)
9
Activity
Badge
Generate
Download
Source code

Advertisement

AutoJson

Contributors..

AutoValue + Json Mapper(LoganSquare).

Usage

parse:

Post post = Post.parse(jsonString);
post.id();
post.isHidden();

or

Post post = LoganSquare.parse(jsonString, AutoJson_Post.class);
post.id();
post.isHidden();

serialize:

Post post = Post.builder().id(1).isHidden(false).build();
String jsonString = post.serialize();

or

String jsonString = Post.builder().id(1).isHidden(false).serailize();

or

Post post = Post.builder().id(1).isHidden(false).build();
String jsonString = LoganSquare.serailize(post);

Post.java:

@AutoJson
public abstract class Post {
    @Nullable
    @AutoJson.Field
    public abstract String id();

    @Nullable
    @AutoJson.Field(name = "is_hidden")
    public abstract Boolean isHidden();

    // ...

    @AutoJson.Builder
    public static abstract class Builder {
        public abstract Builder id(String id);
        public abstract Builder isHidden(Boolean isHidden);
        public static Post build();
    }
    public static Builder builder();
}

Installation

via jcenter:

repositories {
    jcenter()
}

dependencies {
    compile 'com.infstory:auto-json:1.0.3'
    apt 'com.infstory:auto-json-processor:1.0.3'
}

via jitpack.io:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    compile 'com.github.yongjhih.auto-json:auto-json:-SNAPSHOT'
    apt 'com.github.yongjhih.auto-json:auto-json-processor:-SNAPSHOT'
}

Credit

License

Copyright 2015 8tory, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.