JSON is now popular Universal data format, Android is not very convenient for its operation, although there are Gson and other Lib.instagram new Ig-json-parse automated operation, automatic serialization and deserialization, very convenient.
Is that the official did not use studio, configure the operation cost me some time. Now share the successful configuration file, the Build.gradle (project build file under the non-root directory) in the app directory to add the following configuration information:
Apply plugin: ' Com.android.application 'ext { generatedsourcesdir = File ("Gen-src/main/java" )}repositories {mavencentral ()}android {compilesdkversion11buildtoolsversion"20.0.0"Defaultconfig {ApplicationID"XXXXXX"minsdkversion11targetsdkversion11 }Sourcesets {main {java { srcdir generatedsourcesdir } }} buildtypes {release {Runproguardfalseproguardfiles Getdefaultproguardfile (' Proguard-android.txt '), ' proguard-rules.txt '}}}dependencies {compile Filetree (dir:' Libs ', include: ' *.jar ')compile ' com.instagram:ig-json-parser-processor:0.0.4+ '}Tasks.withtype (javacompile) {dofirst { //Regenerate All Files if (generatedsourcesdir.exists ()) {Generatedsourcesdir.deletedir ()} Generatedsourcesdir.mkdirs ()} Options.compilerargs + = ['-processor ', ' Com.instagram. Common.json.annotation.processor.JsonAnnotationProcessor ', '-s ', Generatedsourcesdir]}
Then click on the button to compile, will automatically generate helper class, parsing and serialization work.
Refer to GitHub's official instructions for how to use the specific library.
Https://github.com/Instagram/ig-json-parser
Android Studio uses the Instagram ig-gson-parse class library configuration