Android Parsing JSON


When developing application at some time, you need to communicate with web service for data exchange. If your communication uses JOSN (JavaScript Object Notation) for data transfer, you may start finding the easiest library available for the JSON, however there are plenty of libraries for JSON library for JAVA.

The one which I found suitable for my need is:

JSON-java License : MIT

Author : Sean Leary

In this article, I will share how to parse JSON using JSON-Java in Android, however the snippet is not limited to Android only.

Getting Started

  1. Download the library from
    Download the source as ZIP from the github.

  2. Extract the files from the zip.
  3. Open Android-Studio.
  4. Right click the Java folder, navigate to New->Package.

  5. Select the destination directory as main\java, click on OK button.

  6. Enter package name as org.json and click on OK button.

  7. Now copy all the JSON-java .java from the source folder and copy them to Android-Studio org.json package.

  8. Build the Android project to ensure that everything is ok.
  9. Now you are ready to use JSON library in your project.


To parse rates from the below JSON text.


Java code to iterate over all the rates.

String jsonText = "{\"base\":\"USD\",\"date\":\"2017-02-17\",\"rates\":

 JSONObject parseJson = new JSONObject(jsonText);
 JSONObject rates = parseJson.getJSONObject("rates");
 Iterator itr = rates.keys();
 while (itr.hasNext()) {
 String data = (String);