/ Json

JsonAnnotation can speed up Android development

JsonAnnotation can speed up Android development

JsonAnnotation

JsonAnnotation can speed up Android development.

It generates gson model class by json string automatically and lets you concentrate on what's really important.

Demo

1.Copy url and json string into JsonAnnotation
api_json
2.Just write a jsonModel name
jsonModel
3.Build the project
(->Make Project)
build
Then you can use UserInfo to do something~

GIF Demo
Picture is big,wait a minute...
json2Model

Usage

1.Add apt in project's build.gradle
[apt][https://bitbucket.org/hvisser/android-apt]

	dependencies {
    	//...
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7'
    }

2.Add apt plugin below apply plugin: 'com.android.application'

apply plugin: 'android-apt'

3.add jsonAnnotation.jar in lib
lib

Download Jar:https://github.com/tianzhijiexian/JsonAnnotation/blob/master/lib/build/libs/lib.jar

Question

@Json2Model(modelName = "UserInfo",jsonStr = "{\n"
            + "    \"id\": 100,\n"
            + "    \"body\": \"It is my post\",\n"
            + "    \"number\": 0.13,\n"
            + "    \"created_at\": \"2014-05-22 19:12:38\"\n"
            + "}")
    String SEARCH_URSER_INFO = "search/user"; // api url

1. Why we need build project?
Unfortunately,Android does not(yet)understand the concept of a compile-time-only dependency, so you need to mess with your build files to make it work.

2. Efficiency
@Json2Model will run in compile-time and models are created before generate apk file.Using JsonAnnotation,developers can let it generate the plumbing code at compile time.Reflect is not in this project,you needn't worry about efficiency questions.

3. Where are models
@Json2Model will create models is out of your own project.You can find theme in:
app(your model name)/build/generated/source/apt/debug/...
model
You should edit these models by edit your jsonString.

GitHub