JSON parsing in Android Studio 1.5.1

后端 未结 2 1003
暖寄归人
暖寄归人 2021-01-29 03:56

I did JSON parsing on Eclipse ADT and it was running perfectly. But when used the same code on Android Studio it was showing error in DefaultHttpClient and every other word in t

相关标签:
2条回答
  • 2021-01-29 04:41

    I strongly recommend you to use a library to to this job. You could use GSON lib (developed by google) or Jackson lib. For the requests you could use Retrofit lib (developed by Square).

    0 讨论(0)
  • 2021-01-29 04:55

    add Gson dependency in build.gradle

    compile 'com.google.code.gson:gson:2.4'
    

    then create POJO class for json response.

    for that just copy your json response string into below link.

    json to pojo converter

    give your class name and package name in righ side form and download that file.

    now come back in our app code.

    Demo demo = new Gson().fromJson("JSON STRING",Demo.class);
    

    Demo is our POJO class which we have created from json to pojo converter

    0 讨论(0)
提交回复
热议问题