Android JSON Parsing from URL – Here i share with how to get json values through android. Which is fetch the JSON value from url,it’s parses the JSON value & list the data. JSON is the best alternative for XML. JSON is not a markup language, so no need to define new tags or attributes to represent the data. We use android third party library to parse the JSON value in android.

Android JSON Parsing from URL

In previous post i’ve explain how make Android Slider Navigation Menu Here

Android JSON Parsing from URL

Before moving JSON parsing, you have some knowledge about JSON. It’s like JSON Object & Array. First you have understand th differences between object & array.

JSON Object

A JSON object contains key/value pairs. JSON(JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.

JSON Array

The [ (square bracket) represents the json array.

that’s all, i hope now you have some ideas in difference between JSON Obkect & Array.

Make New Project

Now time to create new project,

1. Create New project, File–>New project

2. Then choose the Empty Activity

After creating project, you have create one class the class name like HttpHandler.java. In below i have include the HttpHandler.java file. The code like,

View the Main Activity Files (activity_main.xml)

Now, you have to open activity.main.xml make the list of JSON parsing data’s. The activity_main.xml code like,

Hereafter create one xml file, the name is list_item.xml used for list the all values from JSON. The code is,

Parsing JSON in MainActivity

Get the value of JSON, to make the Http call for fetch the JSON value. There are many library file will be there in fetch the JSON values like, volley library & retrofit library etc. The volley library and retrofit library commonly used for parse the JSON value. Finally, the MainActivity.java code like,

Make Internet Connection

Now, you have to enable the internet connection to fetch the JSON value from Server. So just add the following code in your AndroidManifest.xml file. The code is,

The complete code of AndroidManifest.xml like,

Execute the Application

Now you have run your application in android emulator. The exact output like,

Android JSON Parsing from URL