Parse JSON responses with Gson

Keyboard Shortcuts

Once you have some data in JSON format, and you’ve created POJO classes to contain that data, you’re ready to transform it. There are a number of ways to do that. I particularly like using an open-source library from Google named GSon.

- [Instructor] Once you have some data in Json format,…and you've created POJO classes to contain that data,…you're ready to transform it.…There are a number of ways to do this.…I particularly like using an open source…library from Google, named Gson.…In order to use this library you have to add it…as a dependency to your project.…Go to the Menu and select File, Project Structure.…Go to the app Module and click the Dependencies tab.…Then click the plus icon, you'll find it on the…right side on Windows and below the list window on Mac.…

Choose Library Dependency, type gson, g-s-o-n…and click the search icon and you'll see…a bunch of libraries displayed.…You're looking for this one, starting…with com.google.code.gson:gson.…And just take whichever version you see here.…It'll always be the most recent version.…Click OK, click OK again and that adds…the dependency to your Gradle build file.…And automatically re syncs the project.…This line of code has been added.…

I'm compiling in the Gson library…and I don't need to go get a JAR file.…

Resume Transcript Auto-Scroll

Author

Updated

9/14/2017

Released

1/27/2017

Android integrates with a variety of cloud-based and custom web services in a variety of ways, including RESTful services created in PHP or Java, to get, update, and send data over the web. This course shows how you can take advantage of web services, integrations, and libraries to optimize how your app handles network connectivity, errors, data management, and more.

IInstructor David Gassner starts with an overview discussion about available networking strategies, and then dives into how to declare networking permissions, make network requests, handle responses, parse data returned from a web service, and pass user credentials to services that support HTTP basic authentication. He also provides an overview of popular higher-level networking libraries, including OkHttp and Picasso, and offers recommendations for improving performance in network-connected apps. David also covers using static feeds, using dynamic PHP pages hosted on a public server web service, and integrating apps with network data storage.