Click here to Skip to main content
13,510,830 members
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 7 Jul 2017

Android Parsing JSON

, 14 Jul 2017
Rate this:
Please Sign up or sign in to vote.
In this article, I will share how to parse JSON using JSON-Java in Android, however the snippet is not limited to Android only.

Ref :

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\":

  // First get complete Json
  JSONObject parseJson = new JSONObject(jsonText);
  // get the Rate object
  JSONObject rates = parseJson.getJSONObject("rates");
  // Iterate for all the rates
  Iterator itr = rates.keys();
  // loop
  while (itr.hasNext()) {
   String data = (String);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

India India
No Biography provided

You may also be interested in...


Comments and Discussions

PraiseThanks Pin
EdwardEtheridge19647-Jul-17 7:36
memberEdwardEtheridge19647-Jul-17 7:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180417.1 | Last Updated 14 Jul 2017
Article Copyright 2017 by hexgear
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid