AutoJson icon indicating copy to clipboard operation
AutoJson copied to clipboard

AutoLoganSquare = AutoValue + LoganSquare

AutoJson

Android Arsenal Download JitPack Build Status Join the chat at https://gitter.im/yongjhih/AutoJson

Contributors..

auto-json

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

  • https://github.com/frankiesardo/auto-parcel
  • https://github.com/bluelinelabs/LoganSquare

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.