JSON is very light weight, structured, easy to parse and much human readable. JSON is best alternative to XML when your android app needs to interchange data with your server. If your app consuming XML data, you can always refer to Android XML Parsing Tutorial.

In this tutorial we are going to learn how to parse JSON in android using different ways, using java.net library and other third part libraries.

The Sample JSON

Following is the sample JSON that we are going to parse in this tutorial. This is very simple JSON which gives us list of contacts where each node contains contact information like name, email, address, gender and phone numbers.

You can get this JSON data by accessing https://api.androidhive.info/contacts/

{
    "contacts": [
        {
                "id": "c200",
                "name": "Ravi Tamada",
                "email": "ravi@gmail.com",
                "address": "xx-xx-xxxx,x - street, x - country",
                "gender" : "male",
                "phone": {
                    "mobile": "+91 0000000000",
                    "home": "00 000000",
                    "office": "00 000000"
                }
        },
        {
                "id": "c201",
                "name": "Johnny Depp",
                "email": "johnny_depp@gmail.com",
                "address": "xx-xx-xxxx,x - street, x - country",
                "gender" : "male",
                "phone": {
                    "mobile": "+91 0000000000",
                    "home": "00 000000",
                    "office": "00 000000"
                }
        },
        .
        .
        .
        .
  ]
}

The difference between [ and { – (Square brackets and Curly brackets)

In general all the JSON nodes will start with a square bracket or with a curly bracket. The difference between [ and { is, the square bracket ([) represents starting of an JSONArray node whereas curly bracket ({) represents JSONObject. So while accessing these nodes we need to call appropriate method to access the data.

If your JSON node starts with [, then we should use getJSONArray() method. Same as if the node starts with {, then we should use getJSONObject() method.

json parsing structor

1. Creating New Project

So let’s start by creating a new android project. We’ll build a simple app which fetches the json from url, parses it and displays the contacts in a list view. Here we’ll use import java.net libraries (which are natively supported in android) to make the http call and fetch the json from url.

1. Create a new project in Android Studio from File โ‡’ New Project and fill out the required details.

2. As we are fetching the JSON by making HTTP calls, we need to add INTERNET permission in AndroidManifest.xml file. Open AndroidManifest.xml and add the following permission.

<uses-permission android:name="android.permission.INTERNET" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="info.androidhive.jsonparsing" >

    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity android:name=".MainActivity" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

3. Create a class named HttpHandler.java and use the below code. Here makeServiceCall() makes http call to particular url and fetches the response. In our case, we use this to get the raw json from the url.

package info.androidhive.jsonparsing;

import android.util.Log;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;

/**
 * Created by Ravi Tamada on 01/09/16.
 * www.androidhive.info
 */
public class HttpHandler {

    private static final String TAG = HttpHandler.class.getSimpleName();

    public HttpHandler() {
    }

    public String makeServiceCall(String reqUrl) {
        String response = null;
        try {
            URL url = new URL(reqUrl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            // read the response
            InputStream in = new BufferedInputStream(conn.getInputStream());
            response = convertStreamToString(in);
        } catch (MalformedURLException e) {
            Log.e(TAG, "MalformedURLException: " + e.getMessage());
        } catch (ProtocolException e) {
            Log.e(TAG, "ProtocolException: " + e.getMessage());
        } catch (IOException e) {
            Log.e(TAG, "IOException: " + e.getMessage());
        } catch (Exception e) {
            Log.e(TAG, "Exception: " + e.getMessage());
        }
        return response;
    }

    private String convertStreamToString(InputStream is) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();

        String line;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line).append('\n');
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}

4. Before making the http call, let’s add a list view first in our view. Open the layout file of main activity (activity_main.xml) and add a ListView element.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="info.androidhive.jsonparsing.MainActivity">

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
</RelativeLayout>

5. Create another layout file named list_item.xml with following content. This will be used to render single list item view.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="@dimen/activity_horizontal_margin">

    <TextView
        android:id="@+id/name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="2dip"
        android:paddingTop="6dip"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="16sp"
        android:textStyle="bold" />

    <TextView
        android:id="@+id/email"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="2dip"
        android:textColor="@color/colorAccent" />

    <TextView
        android:id="@+id/mobile"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#5d5d5d"
        android:textStyle="bold" />
</LinearLayout>

6. Open MainActivity.java and declare the necessary variables for the list view. If you haven’t worked with list view yet, Android ListView Tutorial will helps you in getting started.

public class MainActivity extends AppCompatActivity {

    private String TAG = MainActivity.class.getSimpleName();

    private ProgressDialog pDialog;
    private ListView lv;

    // URL to get contacts JSON
    private static String url = "https://api.androidhive.info/contacts/";

    ArrayList<HashMap<String, String>> contactList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        contactList = new ArrayList<>();

        lv = (ListView) findViewById(R.id.list);
    }
}

1.1 Downloading & Parsing the JSON

7. As we are getting the JSON by making HTTP call, I am adding a Async class GetContacts to make http calls on background thread. Add the following method in your main activity class.

In onPreExecute() method progress dialog is shown before making the http call.

In doInBackground() method, makeServiceCall() is called to get the json from url. Once the json is fetched, it is parsed and each contact is added to array list.

In onPostExecute() method the progress dialog is dismissed and the array list data is displayed in list view using an adapter.

Also note that I have used getJSONArray() or getJSONObject() method depending on the type of node.

package info.androidhive.jsonparsing;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;

public class MainActivity extends AppCompatActivity {

    private String TAG = MainActivity.class.getSimpleName();

    private ProgressDialog pDialog;
    private ListView lv;

    // URL to get contacts JSON
    private static String url = "https://api.androidhive.info/contacts/";

    ArrayList<HashMap<String, String>> contactList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        contactList = new ArrayList<>();

        lv = (ListView) findViewById(R.id.list);

        new GetContacts().execute();
    }

    /**
     * Async task class to get json by making HTTP call
     */
    private class GetContacts extends AsyncTask<Void, Void, Void> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            // Showing progress dialog
            pDialog = new ProgressDialog(MainActivity.this);
            pDialog.setMessage("Please wait...");
            pDialog.setCancelable(false);
            pDialog.show();

        }

        @Override
        protected Void doInBackground(Void... arg0) {
            HttpHandler sh = new HttpHandler();

            // Making a request to url and getting response
            String jsonStr = sh.makeServiceCall(url);

            Log.e(TAG, "Response from url: " + jsonStr);

            if (jsonStr != null) {
                try {
                    JSONObject jsonObj = new JSONObject(jsonStr);

                    // Getting JSON Array node
                    JSONArray contacts = jsonObj.getJSONArray("contacts");

                    // looping through All Contacts
                    for (int i = 0; i < contacts.length(); i++) {
                        JSONObject c = contacts.getJSONObject(i);

                        String id = c.getString("id");
                        String name = c.getString("name");
                        String email = c.getString("email");
                        String address = c.getString("address");
                        String gender = c.getString("gender");

                        // Phone node is JSON Object
                        JSONObject phone = c.getJSONObject("phone");
                        String mobile = phone.getString("mobile");
                        String home = phone.getString("home");
                        String office = phone.getString("office");

                        // tmp hash map for single contact
                        HashMap<String, String> contact = new HashMap<>();

                        // adding each child node to HashMap key => value
                        contact.put("id", id);
                        contact.put("name", name);
                        contact.put("email", email);
                        contact.put("mobile", mobile);

                        // adding contact to contact list
                        contactList.add(contact);
                    }
                } catch (final JSONException e) {
                    Log.e(TAG, "Json parsing error: " + e.getMessage());
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(getApplicationContext(),
                                    "Json parsing error: " + e.getMessage(),
                                    Toast.LENGTH_LONG)
                                    .show();
                        }
                    });

                }
            } else {
                Log.e(TAG, "Couldn't get json from server.");
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(getApplicationContext(),
                                "Couldn't get json from server. Check LogCat for possible errors!",
                                Toast.LENGTH_LONG)
                                .show();
                    }
                });

            }

            return null;
        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            if (pDialog.isShowing())
                pDialog.dismiss();
            /**
             * Updating parsed JSON data into ListView
             * */
            ListAdapter adapter = new SimpleAdapter(
                    MainActivity.this, contactList,
                    R.layout.list_item, new String[]{"name", "email",
                    "mobile"}, new int[]{R.id.name,
                    R.id.email, R.id.mobile});

            lv.setAdapter(adapter);
        }

    }
}

If you run the project, you can see json data populated into list view as shown in the below image.

android json parsing tutorial

2. Json Parsing using Library

The above method is very easy for simpler json. If the json is very complex, it is better to consider the third party libraries as they are much faster and reliable. Below are the popular libraries used to parse the json.

2.1 Using Volley Library

Volley HTTP library provides easy way to make networks calls. In Android JSON parsing using Volley you can learn how to do that same in easy way using volley networking library which provides you lot of advantages like success/error callback methods and cache options.

2.2 Using Retrofit Library

Retrofit is much popular than volley. The parsing is done using jackson libraries in which you just have to create models for json nodes and the library automatically converts the json into appropriate objects. Go through Android Working with Retrofit HTTP Library which explains in detail about retrofit library.

Change Log

Updated On 27th Dec 2013 (Content Update, Bug fixes)
1st Sep 2016 (Content Update, Bug fixes, latest libraries)
Ravi is hardcore Android programmer and Android programming has been his passion since he compiled his first hello-world program. Solving real problems of Android developers through tutorials has always been interesting part for him.
  • Pingback: Android Login and Registration with PHP, MySQL and SQLite()

  • Mika Octo Frentzen

    where i can put JSON Post in this Project?

    • This is a beginner tutorial. Use Volley or Retrofit as mentioned at the bottom of the article.

  • Elena Smith

    How can you add a search functionality to this?

  • Ahmed El-Elaimy

    how can I parse Image not only text?

  • Aishwary

    it is showing an error as value of type java.lang.String can not be converted into JSON Object, when creating a JSON Object by passing the json string.

  • Kyle

    Nice guide! The url though needs to be changed to https as the site seams to auto-redirect from http

    • I think url is updated to https already. Did I forgot to update it somewhere else?

      • Luisho

        In the MainActivity.java the http’s’ is missing. Thanks for the tutorial!

        • Ok. Look into other advanced json parsing article mentioned at the bottom of the article.

  • Isma’il H.A. Ibn Thomas-Benge,

    Nice tutorial!
    If I wanted to fetuses in put to change the url, how would I do that?
    Example: if I wanted a editTextBox with a submit button: how could I make the user input into a variable and insert into the url string and return the Jason upon clicking the submit button using your code?

  • Kunal

    How we do this from the fragment?

  • Okay. The site is moved to https recently. I need to update all the articles.

  • jagan

    Hi ravi, i went through your tutorials.all are good, pretty useful… i went on developing an android app [native app] for existing web app. the existing app is related to particular organisation. i went on implementing web service, but i am getting null response from the url, even connection is successful. in othercase if i hit the url in browser getting response.

    could you please help me on this. also attached a file. Thanks

    https://uploads.disquscdn.com/images/dea01c1db21769ee49fd220573ae0ecc38d96228b87d41e8cf4f9f6a3423ca5e.png

  • Remache Amine
    • Mehul Rana

      hey….how did u solve this… ??

      • This will happen when json is not proper. It might have php or other errors printed in the response. Check for server logs or use Postman to see the php errors.

  • AngeL RodrigueZ

    Hi super good explained !! I congratulate you!!!!
    Already only one question will you have an example through POST ?? As a Login …

  • akash

    when i run this program i get error saying JSON parsing error value cannot be converted into JSONObject. what to do

  • Basri Umar

    same as me, just view that image
    how to solve?

  • You need to buy a hosting and a web domain address. This article will give you some information.
    https://www.androidhive.info/2015/03/android-hosting-php-mysql-restful-services-to-digitalocean/

  • Emin

    Hello, good tutorial but i cant click listview or items of listview. I tried myListView.setOnItemClickListener(new AdapterView.OnItemClickListener(). Do you have any solution ?

  • Sanchi Bansal

    I want to be able to click on an options menu item to change JSON data in ListView accordingly.
    How do i do it?
    How do I refresh my listview?

  • Ashutosh Choudhary

    how to open an url, by passing it in json string, how to make it clickable in your above code.waiting for your response thanks https://uploads.disquscdn.com/images/0e67dd4953fe398679c22214d55d2905549be877c73f1fcdd8add2966eca0c01.png

  • Amir

    hello

    How to Parse JSON Show Images in upper example?

  • Chaimaa Elfa

    hello sir,
    thank you for this helpfull tutorial its working for me,i have a question :
    my JSON data contains images ,how can i parse it into a listview (like the upper example )?
    thank you

  • Swayam Singh

    pls ravi sir tell me how to solve it.

    E/HttpHandler: IOException: Unable to resolve host “api.androidhive.info”: No address associated with hostnam

    E/MainActivity: Response from url: null

    E/MainActivity: Couldn’t get json from server.

    • Is the device having internet connection? Also have you added INTERNET permission in manifest file?

  • Can you post the error you are getting?

    • jay

      0)
      {
      // looping through all results
      // products node

      while ($row = mysql_fetch_array($result))
      {
      // temp user arrayId`, `Uname`, `Password`, `Aclocked`
      array_push($res,array(
      ‘id’ => $row[“Id”],
      ‘uname’ => $row[“Uname”],
      ‘pass’ => $row[“Password”],
      ‘ac’ => $row[“Aclocked”]));

      // push single product into final response array

      }

      // success

      // echoing JSON response
      echo json_encode($res);
      }

      ?>

      • Access the url in the browser. It has to echo proper json.

  • Chaimaa Elfa

    hi,
    i need some help plz
    i did the same thing mentionned in this tutorial ,now i want to display this information to another activity when one item from the listview is clicked
    how can i do it ?

  • Devesh Pandya

    i am getting at data of type org.json.JSONObject cannot be converted to JSONArray this error while passing my json. i have checked its a valid json format. can u plz help me out on this.

    i found the solutions for this but didnt got any proper solution.

  • Both json are different. Mine starts with an object, your’s is array. You need to parse accordingly.

    • Maker Labz

      In ma case its showing the Toast “Couldn’t get json from server. Check LogCat for possible errors….

  • Bindiya S

    hi, this code works fine..but it gives null for jsonstr if i use my own api url. application terminates at InputStream in = new BufferedInputStream(conn.getInputStream());
    It will not proceed to the convertStreamToString(). why so? plz help me out.

  • Mehmet Balbay

    Thank you for tutorial .

  • kapil

    can you please tell me php code for this

  • kapil

    https://uploads.disquscdn.com/images/1302a61015340ee58d505344f83ecb7c677b6a336545a0923c8b15dc0d174f62.png The data is not showing in listview. instead of listview it is showing on logcat. please help

  • You are parsing the JSON wrong. It starts with Array, but are parsing it as object. Using the same code for all the jsons won’t work. You need to understand the parsing correctly, use appropriately to your json.

    • kapil

      can you suggest me how to pass json in my code

  • cheikhouna gueye

    Hi i have this error i need your help

    1-04 17:19:35.389 22965-22991/udemy.training.com.androidjsonparse E/MainActivity: Response from url:
    301 Moved Permanently

    301 Moved Permanently
    nginx/1.10.3 (Ubuntu)

    11-04 17:19:35.389 22965-22991/udemy.training.com.androidjsonparse E/MainActivity: Json parsing error: Value of type java.lang.String cannot be converted to JSONObject
    11-04 17:19:35.489 22965-22965/udemy.training.com.androidjsonparse E/ViewRootImpl: sendUserActionEvent() mView == null

    • The url is not providing the json. Open the url in browser and see.

      • cheikhouna gueye

        Ok i see! It’s okay. I solved the problem. thank you

        • You are welcome ๐Ÿ™‚

        • Kashish Khurana

          How did u solve this problem?

  • Aditya

    I have downloaded your .apk file.
    But I am getting error while running the app and the error is
    Json parsing error: Value of type java.lang.String cannot be converted to JSONObject

    • Which json url you are testing with? Seems json is not proper.

  • ู…ุญู…ุฏ ุงูˆูŠุณ ุฌู…ูŠู„
    • ู…ุญู…ุฏ ุงูˆูŠุณ ุฌู…ูŠู„

      i solved the problem .i have to make just jason arry first .thanks man .your code is working perfectly

  • cornelius kimutai

    What of Recylerview in place of Listview? How do I go about it?

  • Saqib Rauf

    Download apk provided in tutorial. But it display an error Value of type java.lang.String cannot be converted to JSONObject

    • I see the problem. The site is recently moved to https, and the apk is still older (which points to http instead of https). I’ll upload the newer apk later.

      Thanks for your notice.

      • Machhindra Sudke

        i got same error.. i think your site not update from last 25days???

  • Dinesh

    I want to print my Error from “onErrorResponse” using volley in android, i want to print them separately in different textview.

    my error from onErrorResponse

    {
    “message”: “422 Unprocessable Entity”,
    “error”: {

    “username”: [
    “The username has already been taken.”
    ],
    “email”: [
    “The email has already been taken.”
    ]
    },
    “status_code”: 422
    }
    so i want to print them separately, i mean “The username has already been taken.” in one textview and “The email has already been taken.” in 2nd textview. thank

  • Exynos SnapDragon

    I parsed 2 json sources into 2 separate arraylists using the method above.
    List1: [{name=” ” ,count=” ” }]
    List2: [{name=” ” ,change=” ” }].
    I want to merge these 2 arraylists to form 1 arraylist with 3 fields like [{name=” ” ,count=” ” ,change=” ” }].
    How can i do this? I tried
    combined.addAll(List1)
    combined.addAll(List2)
    but the output only contains 2 fields, not the 3 fields that i would like.

  • Suhas Ar

    Hello, thank you for the post,
    here i have some issue in getting data by onclick event, i have got position by onClick and the entire data of the view that is: “{id=123, Age=25, sex=Male, address=House No.:18, guardianName=xyz, name=abc}”, but here i need each value separately like id,age,name etc. can you please help me out in this. tried lot many ways but am looking for best practice.

    Thanks in advance.

  • Ban Midou

    nice tutorial , very easy to understand, by doing it 2-3 times i’ve learned it very well…….. thank you ravi ,
    now going through volley library……

    • Cool. After volley, learn Retrofit.

      • Ban Midou

        Yupp…….. ^_^

  • Forwa Elade

    Hello Ravi,
    Thanks very much for this tutorial,
    I have been touring the web for days now and wasn’t still able to do this until i found your tutorial.
    Thanks again once more and may the Almighty bless you in abundant.

    • You are welcome Forwa. Be sure to check the same json parsing using Volley and Retrofit.

      Happy Coding ๐Ÿ™‚

  • Machhindra Sudke

    please check your wifi or network is on

  • Farrukh Saleem

    Hello Sir Ravi Tamada.
    i am using your tutorial it is fine but i have error when i run it
    error is ” Json Parsing Error: no value for contact”

    this is my code.
    package info.androidhive.jsonparsing;

    import android.app.ProgressDialog;
    import android.os.AsyncTask;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.util.Log;
    import android.widget.ListAdapter;
    import android.widget.ListView;
    import android.widget.SimpleAdapter;
    import android.widget.Toast;

    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;

    import java.util.ArrayList;
    import java.util.HashMap;

    public class MainActivity extends AppCompatActivity {

    // ArrayList ID = new ArrayList();
    // ArrayList BarCode = new ArrayList();

    private String TAG = MainActivity.class.getSimpleName();

    private ProgressDialog pDialog;
    private ListView lv;

    // URL to get contacts JSON
    private static String url = “http://192.168.15.127:8198/api/Traffic/GetLicenceHolder/?strBarCode=123456”;

    ArrayList<HashMap> EmployeeList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    EmployeeList = new ArrayList();

    lv = (ListView) findViewById(R.id.list);

    new GetContacts().execute();
    }

    /**
    * Async task class to get json by making HTTP call
    */
    private class GetContacts extends AsyncTask {

    // @Override
    // protected void onPreExecute() {
    // super.onPreExecute();
    // // Showing progress dialog
    // pDialog = new ProgressDialog(MainActivity.this);
    // pDialog.setMessage(“Please wait…”);
    // pDialog.setCancelable(false);
    // pDialog.show();
    //
    // }

    @Override
    protected Void doInBackground(Void… arg0) {
    HttpHandler sh = new HttpHandler();

    // Making a request to url and getting response
    String jsonStr = sh.makeServiceCall(url);

    Log.e(TAG, “Response from url: ” + jsonStr);

    if (jsonStr != null) {
    try {
    JSONObject jsonObj = new JSONObject(jsonStr);

    // Getting JSON Array node
    JSONArray contacts = jsonObj.getJSONArray(“contacts”);

    // looping through All Contacts
    for (int i = 0; i < contacts.length(); i++) {
    JSONObject c = contacts.getJSONObject(i);

    String id = c.getString("ID");
    String BarCode = c.getString("BarCode");
    String E_name = c.getString("Employee Name");
    String E_address = c.getString("Employee Address");
    String E_email = c.getString("Employee Email");
    String phonenmbr = c.getString("Employee PhoneNo.");
    String status = c.getString("Status");

    // String id = c.getString("id");
    // String name = c.getString("name");
    // String email = c.getString("email");
    // String address = c.getString("address");
    // String gender = c.getString("gender");

    // Phone node is JSON Object
    JSONObject phone = c.getJSONObject("phone");
    String mobile = phone.getString("mobile");
    String home = phone.getString("home");
    String office = phone.getString("office");

    // tmp hash map for single contact
    HashMap contact = new HashMap();

    // adding each child node to HashMap key => value
    contact.put(“ID”, id);
    contact.put(“BarCode”, BarCode);
    contact.put(“Employee Name”, E_name);
    contact.put(“Employee Address”, E_address);
    contact.put(“Employee Email”,E_email);
    contact.put(“Employee PhoneNo.”,phonenmbr);
    contact.put(“Status”,status);

    // JSONObject id = c.getJSONObject(“ID”);
    // String BarCode = BarCode.get

    // adding contact to contact list
    EmployeeList.add(contact);
    }
    } catch (final JSONException e) {
    Log.e(TAG, “Json parsing error: ” + e.getMessage());
    runOnUiThread(new Runnable() {
    @Override
    public void run() {
    Toast.makeText(getApplicationContext(),
    “Json parsing error: ” + e.getMessage(),
    Toast.LENGTH_LONG)
    .show();
    }
    });

    }
    } else {
    Log.e(TAG, “Couldn’t get json from server.”);
    runOnUiThread(new Runnable() {
    @Override
    public void run() {
    Toast.makeText(getApplicationContext(),
    “Couldn’t get json from server. Check LogCat for possible errors!”,
    Toast.LENGTH_LONG)
    .show();
    }
    });

    }

    return null;
    }

    @Override
    protected void onPostExecute(Void result) {
    super.onPostExecute(result);
    // Dismiss the progress dialog
    // if (pDialog.isShowing())
    // pDialog.dismiss();
    /**
    * Updating parsed JSON data into ListView
    * */
    ListAdapter adapter = new SimpleAdapter(
    MainActivity.this, EmployeeList,
    R.layout.list_item, new String[]{“ID”, “BARCODE”,”EmployeeName”,”EmployeeAddress”,”EmployeeEmail”,”EmployeePhoneNo”,”Status”},
    new int[]{R.id.id,R.id.BarCode, R.id.E_name,R.id.E_address,R.id.E_email,R.id.phonenmbr,R.id.status});

    lv.setAdapter(adapter);
    }

    }
    }

    • You need to make sure that the url you are accessing is returning valid json. You can hit the url from Postman and see.

  • Krishna Kumar

    Hello Ravi tamada
    please post a tutorial or sample about quandl api. since its json is of complex

  • Aleks Kosyrev

    Good day to you Ravi!
    Thanks a lot for this tutorial. Found this very usefull for my app, also found so much examples based on this code at stack))
    Please let me know how to use code above to parce json to sqlite and then put it to listview. Spent two days to find appropriate solution.

  • Aleks Kosyrev

    Just faced with exeption “Json parsing error: Value null at percent_change_7d of type org.json.JSONObject$1 cannot be converted to int” How can I edit HttpHandler class to avoid it? Making String response = “”; instead of null not worked.

    • Are you parsing the same response provided in the article?

      • Aleks Kosyrev

        No, error has dissapiared. Think problem was at server side

  • emi

    JSON Parsing error value of type java.lang.string cannot be converted to JSONObject
    The error shows after installing and running your app provided in this article. Can you solve it?

    • Are you trying the below url? The json is loading properly.
      https://api.androidhive.info/contacts/

      If you are trying any other url, it is not responding with json. Instead it has some errors.

      • emi

        no im trying from the same url. Maybe the code it’s not working can you try to install the app?

        • Are you trying the the url with https, not http?

          • emi

            I just download your apk from the source but it’s not working when i open the app

          • Yeah probably the apk still pointing to http url.

  • Hi Deependra

    You can do this very easily.

    1. First of all use RecyclerView to display the information in list. Don’t use the ListView. This article can help in displaying json data in list (ignore search part).
    https://www.androidhive.info/2017/11/android-recyclerview-with-search-filter-functionality/

    2. Second you need to find the item that is clicked. You can attach a click listener to RecyclerView and find the item index selected. Once index is known, you can get the item details from the ArrayList.
    https://www.androidhive.info/2016/01/android-working-with-recycler-view/ You can learn RecyclerView and Click listener here.

    3. Pass the selected item id or name (whatever parameter is required to get complete json of a single item). You can pass the data to another activity via intents.
    https://www.androidhive.info/2011/08/how-to-switch-between-activities-in-android/ This article explains how to send data b/w activities via intents.

    4. On the full details activity, get the item id sent from list activity and fetch the json by making http call again.

    • Deependra

      Thanks for help

  • emi

    Thanks for the tutorial i have a question how to make a onClickListener in order to open something when the user clicks on one of the contact names?

    • Just write on click listener for your list view and pass the contact via intent to another activity.

      • emi

        can you provide me the source code ? I dont understand it sorry

      • emi

        can you write the code please????

  • Could you post the code?

  • Almas Patel

    Hello, can you please provide the solution to parse the json obtain by microsoft api – calendar events from outlook .. Following image is somewhat same to Json response recieved..

    https://uploads.disquscdn.com/images/7cb415e7648fd9cd47819fccfc2d0569f2afb12d12f39a83d6626a63051f0d45.png

    • Have you consider using Gson to parse the json?

      • Almas Patel

        No. I don’t have any idea how to use Gson to parse json

  • Ken Francisco

    Hi sir, I am a newbie in programming, Do you have any guide in firebase with the help of GSON or for localhost (using XAMPP) Thank you, I have an code for generating .json format in my localhost,

    I want the data in the json file will be printed in my textviews in android :).
    Thanks in Advance ๐Ÿ™‚

  • Michael AMP

    Hi, have you tried passing the value of its item into another activity? I have zero idea how to pass the value if the data from json

  • Kunal

    i used this code for showing the list from the json and its working but if i want to go another activity from click the list so how’s it work because i try it but not showing any error and unable to go next activity

  • I didn’t find any problem in the code. You can print a Log in onItemClick method and verify whether the click is working or not. If that is working, verify Toast.class doesn’t have finish() any where.

  • surajit shome

    Hi, Can I get your Server Side Source Code, I am trying to implement same with a different url.

  • Victor Jimenez

    Hello Ravi, could you post your dime.xml? from values?

    thank you in advance

    • Please download the project using the Download Button provided at the top.

  • Shubham Kumar

    showing JSON parsing error : no value for mobile

  • Jeevan Acharya

    How to make android application work online and offline both with server side? and how to sync the server side data?Could u provide me the code as well as the hint

  • Hi Victor

    It’s good that you understood this article and could be able to modify as necessary. But this article is just a beginning. I strongly suggest you use Retrofit or Volley in your project. You can get started with them here.

    My main choice is Retrofit only.
    https://www.androidhive.info/2016/05/android-working-with-retrofit-http-library/
    https://www.androidhive.info/2014/05/android-working-with-volley-library-1/

  • Amit Tandel

    How to write json data to url?

  • Amit Tandel

    Hi Ravi,
    I am getting following error.

    02-20 14:13:34.337 27147-27202/info.androidhive.jsonparsing E/MainActivity: Response from url:
    301 Moved Permanently

    301 Moved Permanently
    nginx/1.10.3 (Ubuntu)

    02-20 14:13:34.338 27147-27202/info.androidhive.jsonparsing E/MainActivity: Json parsing error: Value of type java.lang.String cannot be converted to JSONObject

  • Lakshay

    Hi , just followed your code and getting an error like
    Json parsing error: Value true of type java.lang.Boolean cannot be converted to JSONObject

    • Verify your JSON. You are converting a boolean value to JSONObject.

      • Lakshay

        I used your link only

  • The match is inside data node. You are accessing it directly.

    JSONObject jsonObj = new JSONObject(jsonStr);

    JSONObject jsonObjData = jsonObj.getJSONObject(“data”);

    // Getting JSON Array node
    JSONArray contacts = jsonObj.getJSONArray(“match”);

  • user134431

    Hello. Thanks for the code. Everything works fine until i want to use a parameter. If I want to use the parameter I get the error Json parsing error – No value for events. Am using this
    HashMap params = new HashMap();
    params.put(“get_events”, “club”);

    // Making a request to url and getting response
    String jsonStr = sh.makeServiceCall(URLs.URL_EVENTS, params);

    Have modified the code in HttpHandler as HttpRequest as

    public class HttpRequest {
    private static final String TAG = HttpRequest.class.getSimpleName();
    public HttpRequest() {
    }

    public String makeServiceCall(String requestURL, HashMap postDataParams) {
    String response = null;
    StringBuilder sb ;
    try {
    URL url = new URL(requestURL);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setReadTimeout(15000);
    conn.setConnectTimeout(15000);
    conn.setRequestMethod(“POST”);
    conn.setDoInput(true);
    conn.setDoOutput(true);
    // read the response
    InputStream in = new BufferedInputStream(conn.getInputStream());
    response = convertStreamToString(in);
    OutputStream os = conn.getOutputStream();
    BufferedWriter writer = new BufferedWriter(
    new OutputStreamWriter(os, “UTF-8”));
    writer.write(getPostDataString(postDataParams));

    writer.flush();
    writer.close();
    os.close();
    int responseCode = conn.getResponseCode();

    if (responseCode == HttpsURLConnection.HTTP_OK) {

    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    sb = new StringBuilder();

    while ((response = br.readLine()) != null) {
    sb.append(response);
    }
    }
    } catch (MalformedURLException e) {
    Log.e(TAG, “MalformedURLException: ” + e.getMessage());
    } catch (ProtocolException e) {
    Log.e(TAG, “ProtocolException: ” + e.getMessage());
    } catch (IOException e) {
    Log.e(TAG, “IOException: ” + e.getMessage());
    } catch (Exception e) {
    Log.e(TAG, “Exception: ” + e.getMessage());
    }
    return response;
    }

    private String convertStreamToString(InputStream is) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    StringBuilder sb = new StringBuilder();

    String line;
    try {
    while ((line = reader.readLine()) != null) {
    sb.append(line).append(‘n’);
    }
    } catch (IOException e) {
    e.printStackTrace();
    } finally {
    try {
    is.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    return sb.toString();
    }
    //this method is converting keyvalue pairs data into a query string as needed to send to the server
    private String getPostDataString(HashMap params) throws UnsupportedEncodingException {
    StringBuilder result = new StringBuilder();
    boolean first = true;
    for (Map.Entry entry : params.entrySet()) {
    if (first)
    first = false;
    else
    result.append(“&”);

    result.append(URLEncoder.encode(entry.getKey(), “UTF-8”));
    result.append(“=”);
    result.append(URLEncoder.encode(entry.getValue(), “UTF-8”));
    }

    return result.toString();
    }
    }

  • Maulik Jagtap

    sir data are not fetch on my screen i have right above code

  • Olivier Le Goaer

    You can also paste the JSON URL https://api.androidhive.info/contacts/ into the GenDroid generator : http://gendroid.univ-pau.fr/remoteDatabase.html

  • Naveen Kumar Reddy Pemmana

    Hello sir
    I need an help,
    I need to update the textview which displays a integer value on the mainactivity of android everytime when the app is opened.
    I need to send an post variable ‘Unique_id’ to a php script(URL) . The php script sends a JSON object response.
    This json object response should be received by mainactivity.
    I need to use Asynctask but am unable to do even after lot of Googling .
    Please help me by giving the code for it sir.
    Please.
    Thanks in advance

  • reyhanlibilgi

    how to add a search box

  • Can you create a function where it just shows the “females” in the list when a button is clicked? i.e checks all id’s and just grabs the results with the id “gender” : “female”.

  • Sonu Shekh

    Hi Ravi
    can you tell me how to create you api file actually i am creating a api using c# and my response like that.
    please help…
    This is my response
    [
    {
    “ID”: 101,
    “LoginName”: “Sonu”,
    “UserName”: “Admin”,
    “Password”: “Admin”
    },
    {
    “ID”: 102,
    “LoginName”: “Sonu”,
    “UserName”: “User”,
    “Password”: “pass123”
    },
    {
    “ID”: 103,
    “LoginName”: “Sonu”,
    “UserName”: “lookman”,
    “Password”: “lkmn123”
    },
    {
    “ID”: 104,
    “LoginName”: “Secura”,
    “UserName”: “adme”,
    “Password”: “ad123”
    },
    {
    “ID”: 105,
    “LoginName”: “Secura”,
    “UserName”: “nagur”,
    “Password”: “close”
    },
    {
    “ID”: 106,
    “LoginName”: “Secura”,
    “UserName”: “jdk”,
    “Password”: “open”
    },
    {
    “ID”: 107,
    “LoginName”: “Secura”,
    “UserName”: “admire”,
    “Password”: “test123”
    }
    ]

  • edwin bukachi

    Hi Ravi,
    can i get tutorial on Flatbuffer library

    • I never used it before ๐Ÿ™

      • edwin bukachi

        Thank you Ravi.

  • Manuel Fernรกndez Paradela Ledรณ

    Hello Ravi!
    Many situations (servers that return a JSON response) use a JSON arraY without de root tag, “contacts” in your example. How to get each contact in this case? Thank you. Manuel.

  • Mohammad Ali Kadiwala

    Error come like : Json praising error : no values for contacts, when i debug aap then it’s show {“status”:”0″,”msg”:”Authorization fail!”}

  • emi

    I don’t want to add them into a list view. How to save the json objects into a string ?

    • You get String only after making the HTTP call. You can use that directly.

      • emi

        Which is name of the string? id name email address gender? So i should use them directly ? Like this : Toast.makeText(getApplicationContext(),”This is the ID” id “This is the name” name,Toast.LENGTH_SHORT).show(); ?

  • Mack Tanian

    Hello, I was wondering if you might know anything about turning MIT’s Scratch program files (.sb2) into a fully functioning Native (so it does not need web other than first downloading) Android App by maybe replacing the Scratch editor with a custom built .sb2 Player (minus the block code editor and just showing the game in a window without green flag and stop sign) and placing them together in the .apk file hierarchy in whichever way it needs to be parsed or whatever has to happen for it to work correctly and then be signable so that it can go into the App Stores.

    Do you know anything about this? I believe it is possible but I am unexperienced in programming and know little about how these .JSON files work. .sb2 files seem to just be a zip file of some sort containing .JSON and the graphics files used within the Scratch project which I think means that it has to use a Scratch Player for the code that runs it or it needs a suitable replacement and I would like for it to play as a normal Native Android App would play when tapping on it and load the .sb2 file automatically when the player starts up if at all possible.

    This is what I am trying to learn even though it is all way above my head. I am trying to save on time as I do not really have the time to wait until I have learned Java and everything needed to be known to re-code my game engine prototypes from Scratch. I need to help my family bring in some money and this is all I really know and the few other options are grim and depressing and I am sure that if I could just find a way to convert my projects into real Android Apps I would be able to have money enough coming in to help everyone.

    I have been working on different kinds of movement logic engines in Scratch for a while now and have gotten quite good at it, but that does not translate over to other kinds of coding right away because of the learning curve and remembering syntax and needing to download about 3 – 5 different programs like compilers and sdks and all that other stuff that I don’t understand and will need to learn as well. It all takes so much time. I have some games that are basically ready to go other than a little polishing and all that stands in the way is this insurmountable dead end brick wall of an obstacle. ๐Ÿ™

    • Hi Mack

      I am not sure what you query is. All I can say is without the proper knowledge or intent to learn things you won’t learn or earn anything. Take your time to explor and learn things.

      • Mack Tanian

        Hi Ravioli Tomato, I am not sure why you can’t read and all I have to say is to take time to learn how to read English properly before you go into the tech industry or moderate forums and think you know it all and then shoot down people’s valid questions with half-hearted rancid remarks. Everyone can be short with others see, and it solves nothing for anyone. You were so short with me that you did not even bother to place an e on “explore” or an r at the end of you to form “your”.

        I happen to need to get my programs up and running quickly to make some cash to help my family and your arrogance is not helping. I am making videogames, not anything harmful, so if that is your reasoning and why you were so terse with me, please understand that I am not a scam artist nor do I ever intend to be one. If you don’t know how to help, then just say so. No need to be a kcid about it. I fully intend to learn some Java later, but for now the easiest and best method would be to port over my projects to .apk and then sign them and get them onto an app store.

        I have found one method that may work which is fairly quick but I still have to find out how to sign the .apk and upload it to the store. So it still may not be the solution I need depending on what happens.

        Scratch is a very nice prototyping tool and does everything I need for the kinds of programs I wish to make (small apps / games). So if I can cut out the middle-man and port it straight into an .apk file, why wouldn’t I? Is there some sort of bias you have against MIT? They wouldn’t let you in? If not then why are you so snippy in your reply? You do realize that I just use their tool right?

        I will re-phrase my question so that you may understand:

        Is there a way to translate both the player of the .sb2 files and a
        single .sb2 file (the project information) into an .apk file?

        .sb2 = .json + .png’s + Scratch editor (it plays .sb2 files).
        There is opensource code of the Scratch editor but I would have to gut out just the player part of it. Also it uses Flash which presents problems too.

        So I have to re-code it in Html5 or use the opensource of Scratch 3.0 if it is available and somehow set it up to autoplay the .sb2 file. None of which I know how to do. But I am going to attempt to learn how.

        question reiterated: Is there a way to translate both the player of the .sb2 files and a single .sb2 file (the project information) into an .apk file?

        Learn here to better understand: https://scratch.mit.edu/
        Play with the projects and click See Inside to see a projects code.
        Also look here: https://scratch.mit.edu/discuss/topic/227463/?page=1#post-2308798 And here: https://github.com/LLK/
        Try here then click on choose an example and pick O and you will see what some of what Scratch can do: https://phosphorus.github.io/

        It may be touted as a kids learning program but just like with any tool, if you put it in the right hands it can do some impressive things.

        Implying that I don’t attempt to learn things was not very nice of you but all is forgiven if you answer my question with something useful. At the very least a simple “I don’t know” would suffice. At least you did reply though I guess even if it was the worst reply I have ever seen. Seriously, I’ve seen trolls that make better replies. … I am not exactly the best at writing speech either and am probably too colloquial or otherwise, and definitely too long-winded … .

  • vinayaka dj

    Hi I downloaded your APK and code and tried to run in phone I am getting an error saying Json parsing error value of type java.lang.string cannot be converted to JSONObject

    • Hi vinayaka

      Thats because of https url. The URL is moved to https recently, that’s why you are getting the error. Now I have updated code and apk. Pls check once.

  • Try printing the jsonStr before parsing it.

    String jsonStr = sh.makeServiceCall(url);

    Log.e(TAG, “json response: ” + jsonStr);

    if (jsonStr != null) {
    try {

    • Emad Zedan

      06-10 10:39:26.167 4412-4442/? E/TAG: json response: null
      the response is null

      • Is INTERNET permission added? Open the json url in mobile Chrome and see what happens.

  • himanshu

    i tried using your code but faced some errors. can you tell me how to correct these?

    Logcat-

    06-11 12:18:59.357 15124-15192/com.task.android.androidapptask E/HttpHandler: IOException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

    06-11 12:18:59.357 15124-15192/com.task.android.androidapptask E/MainActivity: Response from url: null

    Couldn’t get json from server.

  • Thank you sir finally this tutorial helped me. But what if i want to parse Images from the json using same way? How can i do it?

  • Pooja

    Hi Ravi, Thanks for your tutorial, it really helped. I’m getting an error at runtime which is OutOfMemoryError in httphandler class. It is also giving me a warning in GetContacts class “This AsyncTask class should be static or leaks might occur”. How do i resolve this? Any suggestions will be appreciable.

    • Hi Pooja

      The code provided in the article is very basic just to understand the http concepts. Try learning about Retrofit and Volley as suggested at the bottom of the article.

  • Mathieu Chevalier

    Hi Ravi, great tuto thank you!

    Is it possible to “attack” url with digest authentication ?

    Thanks in advance.

    Math

    • I am not sure. I need to study.

      • Mathieu Chevalier

        Thank you very much !
        I’m stuck because of that right now

  • Gustav Marcinka

    Please i try this data format and have problem with json, please can you help me with json code?

    [{“celkom_cashflow”:”323″,”prevadzka”:”1″,”celkom_cashflow_mesiac”:”102113″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”25″,”aktualizacia”:”2018-05-18 11:40:00″,”suma_zakazky_mesiac”:”75224.22″,”pocet_zakaziek_mesiac”:”19″,”suma_rp_mesiac”:”13960″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”323″,”celkom_cashflow_mesiac_cz”:”102113″},{“celkom_cashflow”:”0″,”prevadzka”:”1″,”celkom_cashflow_mesiac”:”133140″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:55:00″,”suma_zakazky_mesiac”:”142302.8″,”pocet_zakaziek_mesiac”:”28″,”suma_rp_mesiac”:”14260″,”ico”:”29412714″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”133140″},{“celkom_cashflow”:”0″,”prevadzka”:”1″,”celkom_cashflow_mesiac”:”2722.24″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:54:00″,”suma_zakazky_mesiac”:”3484.98″,”pocet_zakaziek_mesiac”:”22″,”suma_rp_mesiac”:”446.5″,”ico”:”51489759″,”krajina”:”sk”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”69417.12″},{“celkom_cashflow”:”79″,”prevadzka”:”2″,”celkom_cashflow_mesiac”:”141679″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”79″,”aktualizacia”:”2018-05-18 11:56:00″,”suma_zakazky_mesiac”:”123524.6″,”pocet_zakaziek_mesiac”:”39″,”suma_rp_mesiac”:”20022.12″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”79″,”celkom_cashflow_mesiac_cz”:”141679″},{“celkom_cashflow”:”2649″,”prevadzka”:”2″,”celkom_cashflow_mesiac”:”182230″,”pocet_zakaziek”:”2″,”suma_zakazky”:”3766″,”suma_rp”:”99″,”aktualizacia”:”2018-05-18 11:51:00″,”suma_zakazky_mesiac”:”152578.2″,”pocet_zakaziek_mesiac”:”39″,”suma_rp_mesiac”:”4904″,”ico”:”29412714″,”krajina”:”cz”,”celkom_cashflow_cz”:”2649″,”celkom_cashflow_mesiac_cz”:”182230″},{“celkom_cashflow”:”123.5″,”prevadzka”:”2″,”celkom_cashflow_mesiac”:”1274.5″,”pocet_zakaziek”:”1″,”suma_zakazky”:”69″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:45:00″,”suma_zakazky_mesiac”:”1621.5″,”pocet_zakaziek_mesiac”:”11″,”suma_rp_mesiac”:”165″,”ico”:”51489759″,”krajina”:”sk”,”celkom_cashflow_cz”:”3149.25″,”celkom_cashflow_mesiac_cz”:”32499.75″},{“celkom_cashflow”:”9947″,”prevadzka”:”3″,”celkom_cashflow_mesiac”:”214784″,”pocet_zakaziek”:”1″,”suma_zakazky”:”6298″,”suma_rp”:”119″,”aktualizacia”:”2018-05-18 11:54:00″,”suma_zakazky_mesiac”:”157725″,”pocet_zakaziek_mesiac”:”27″,”suma_rp_mesiac”:”28378.05″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”9947″,”celkom_cashflow_mesiac_cz”:”214784″},{“celkom_cashflow”:”2190″,”prevadzka”:”4″,”celkom_cashflow_mesiac”:”163823″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”2190″,”aktualizacia”:”2018-05-18 11:51:00″,”suma_zakazky_mesiac”:”164086.21″,”pocet_zakaziek_mesiac”:”36″,”suma_rp_mesiac”:”15351.01″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”2190″,”celkom_cashflow_mesiac_cz”:”163823″},{“celkom_cashflow”:”377″,”prevadzka”:”5″,”celkom_cashflow_mesiac”:”117581″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”377″,”aktualizacia”:”2018-05-18 11:35:00″,”suma_zakazky_mesiac”:”128935.89″,”pocet_zakaziek_mesiac”:”30″,”suma_rp_mesiac”:”13206″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”377″,”celkom_cashflow_mesiac_cz”:”117581″},{“celkom_cashflow”:”7620″,”prevadzka”:”6″,”celkom_cashflow_mesiac”:”180375″,”pocet_zakaziek”:”1″,”suma_zakazky”:”7620″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:52:00″,”suma_zakazky_mesiac”:”169988.6″,”pocet_zakaziek_mesiac”:”43″,”suma_rp_mesiac”:”14367.02″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”7620″,”celkom_cashflow_mesiac_cz”:”180375″},{“celkom_cashflow”:”6680″,”prevadzka”:”7″,”celkom_cashflow_mesiac”:”89610″,”pocet_zakaziek”:”5″,”suma_zakazky”:”13124″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:46:00″,”suma_zakazky_mesiac”:”60447.6″,”pocet_zakaziek_mesiac”:”21″,”suma_rp_mesiac”:”14090″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”6680″,”celkom_cashflow_mesiac_cz”:”89610″},{“celkom_cashflow”:”6910″,”prevadzka”:”8″,”celkom_cashflow_mesiac”:”214828″,”pocet_zakaziek”:”4″,”suma_zakazky”:”12446″,”suma_rp”:”50″,”aktualizacia”:”2018-05-18 11:52:00″,”suma_zakazky_mesiac”:”210112″,”pocet_zakaziek_mesiac”:”55″,”suma_rp_mesiac”:”5658″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”6910″,”celkom_cashflow_mesiac_cz”:”214828″},{“celkom_cashflow”:”725″,”prevadzka”:”9″,”celkom_cashflow_mesiac”:”327170″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”59″,”aktualizacia”:”2018-05-18 11:44:00″,”suma_zakazky_mesiac”:”206719.4″,”pocet_zakaziek_mesiac”:”35″,”suma_rp_mesiac”:”19108″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”725″,”celkom_cashflow_mesiac_cz”:”327170″},{“celkom_cashflow”:”0″,”prevadzka”:”10″,”celkom_cashflow_mesiac”:”106299″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:48:00″,”suma_zakazky_mesiac”:”88009.8″,”pocet_zakaziek_mesiac”:”27″,”suma_rp_mesiac”:”17958.01″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”106299″},{“celkom_cashflow”:”31431″,”prevadzka”:”11″,”celkom_cashflow_mesiac”:”168908″,”pocet_zakaziek”:”1″,”suma_zakazky”:”3012″,”suma_rp”:”4931.2″,”aktualizacia”:”2018-05-18 11:50:00″,”suma_zakazky_mesiac”:”108133.8″,”pocet_zakaziek_mesiac”:”21″,”suma_rp_mesiac”:”25715.4″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”31431″,”celkom_cashflow_mesiac_cz”:”168908″},{“celkom_cashflow”:”0″,”prevadzka”:”12″,”celkom_cashflow_mesiac”:”60886″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:43:00″,”suma_zakazky_mesiac”:”47910″,”pocet_zakaziek_mesiac”:”24″,”suma_rp_mesiac”:”1128″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”60886″},{“celkom_cashflow”:”4530″,”prevadzka”:”13″,”celkom_cashflow_mesiac”:”221676″,”pocet_zakaziek”:”1″,”suma_zakazky”:”4504″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:42:00″,”suma_zakazky_mesiac”:”214113.2″,”pocet_zakaziek_mesiac”:”45″,”suma_rp_mesiac”:”16085.76″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”4530″,”celkom_cashflow_mesiac_cz”:”221676″},{“celkom_cashflow”:”1917″,”prevadzka”:”14″,”celkom_cashflow_mesiac”:”202388″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”327″,”aktualizacia”:”2018-05-18 11:43:00″,”suma_zakazky_mesiac”:”148038.01″,”pocet_zakaziek_mesiac”:”42″,”suma_rp_mesiac”:”29787″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”1917″,”celkom_cashflow_mesiac_cz”:”202388″},{“celkom_cashflow”:”637″,”prevadzka”:”15″,”celkom_cashflow_mesiac”:”251454″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”637″,”aktualizacia”:”2018-05-18 11:42:00″,”suma_zakazky_mesiac”:”255965.5″,”pocet_zakaziek_mesiac”:”69″,”suma_rp_mesiac”:”23902.3″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”637″,”celkom_cashflow_mesiac_cz”:”251454″},{“celkom_cashflow”:”3866″,”prevadzka”:”16″,”celkom_cashflow_mesiac”:”126837″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”508″,”aktualizacia”:”2018-05-18 11:54:00″,”suma_zakazky_mesiac”:”127741.14″,”pocet_zakaziek_mesiac”:”27″,”suma_rp_mesiac”:”7488″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”3866″,”celkom_cashflow_mesiac_cz”:”126837″},{“celkom_cashflow”:”0″,”prevadzka”:”17″,”celkom_cashflow_mesiac”:”46901″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 10:45:00″,”suma_zakazky_mesiac”:”42955″,”pocet_zakaziek_mesiac”:”15″,”suma_rp_mesiac”:”6567″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”46901″},{“celkom_cashflow”:”34939″,”prevadzka”:”18″,”celkom_cashflow_mesiac”:”110405″,”pocet_zakaziek”:”3″,”suma_zakazky”:”38975.6″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:46:00″,”suma_zakazky_mesiac”:”93109.4″,”pocet_zakaziek_mesiac”:”18″,”suma_rp_mesiac”:”6029.01″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”34939″,”celkom_cashflow_mesiac_cz”:”110405″},{“celkom_cashflow”:”9084″,”prevadzka”:”19″,”celkom_cashflow_mesiac”:”160486″,”pocet_zakaziek”:”2″,”suma_zakazky”:”5926″,”suma_rp”:”100″,”aktualizacia”:”2018-05-18 11:56:00″,”suma_zakazky_mesiac”:”148372″,”pocet_zakaziek_mesiac”:”32″,”suma_rp_mesiac”:”14184″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”9084″,”celkom_cashflow_mesiac_cz”:”160486″},{“celkom_cashflow”:”22234″,”prevadzka”:”20″,”celkom_cashflow_mesiac”:”111350″,”pocet_zakaziek”:”12″,”suma_zakazky”:”31743″,”suma_rp”:”59″,”aktualizacia”:”2018-05-18 11:55:00″,”suma_zakazky_mesiac”:”90084.81″,”pocet_zakaziek_mesiac”:”35″,”suma_rp_mesiac”:”12119″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”22234″,”celkom_cashflow_mesiac_cz”:”111350″},{“celkom_cashflow”:”129″,”prevadzka”:”21″,”celkom_cashflow_mesiac”:”114372″,”pocet_zakaziek”:”1″,”suma_zakazky”:”1500″,”suma_rp”:”129″,”aktualizacia”:”2018-05-18 11:55:00″,”suma_zakazky_mesiac”:”121352.01″,”pocet_zakaziek_mesiac”:”47″,”suma_rp_mesiac”:”2830″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”129″,”celkom_cashflow_mesiac_cz”:”114372″},{“celkom_cashflow”:”10956″,”prevadzka”:”23″,”celkom_cashflow_mesiac”:”151047″,”pocet_zakaziek”:”2″,”suma_zakazky”:”10837″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:45:00″,”suma_zakazky_mesiac”:”128826.22″,”pocet_zakaziek_mesiac”:”30″,”suma_rp_mesiac”:”5867″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”10956″,”celkom_cashflow_mesiac_cz”:”151047″},{“celkom_cashflow”:”1617″,”prevadzka”:”51″,”celkom_cashflow_mesiac”:”180405″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”50″,”aktualizacia”:”2018-05-18 11:44:00″,”suma_zakazky_mesiac”:”143374.63″,”pocet_zakaziek_mesiac”:”38″,”suma_rp_mesiac”:”9021″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”1617″,”celkom_cashflow_mesiac_cz”:”180405″},{“celkom_cashflow”:”18779″,”prevadzka”:”53″,”celkom_cashflow_mesiac”:”52909″,”pocet_zakaziek”:”6″,”suma_zakazky”:”42661″,”suma_rp”:”204″,”aktualizacia”:”2018-05-18 11:45:00″,”suma_zakazky_mesiac”:”68188.41″,”pocet_zakaziek_mesiac”:”13″,”suma_rp_mesiac”:”3255″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”18779″,”celkom_cashflow_mesiac_cz”:”52909″},{“celkom_cashflow”:”15009″,”prevadzka”:”54″,”celkom_cashflow_mesiac”:”60771″,”pocet_zakaziek”:”10″,”suma_zakazky”:”30569″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:52:00″,”suma_zakazky_mesiac”:”76352″,”pocet_zakaziek_mesiac”:”24″,”suma_rp_mesiac”:”9089″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”15009″,”celkom_cashflow_mesiac_cz”:”60771″},{“celkom_cashflow”:”1839″,”prevadzka”:”55″,”celkom_cashflow_mesiac”:”73586″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:56:00″,”suma_zakazky_mesiac”:”52082.93″,”pocet_zakaziek_mesiac”:”16″,”suma_rp_mesiac”:”6084″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”1839″,”celkom_cashflow_mesiac_cz”:”73586″},{“celkom_cashflow”:”0″,”prevadzka”:”56″,”celkom_cashflow_mesiac”:”43889″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:43:00″,”suma_zakazky_mesiac”:”43640.01″,”pocet_zakaziek_mesiac”:”14″,”suma_rp_mesiac”:”4769″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”43889″},{“celkom_cashflow”:”5760″,”prevadzka”:”57″,”celkom_cashflow_mesiac”:”85696″,”pocet_zakaziek”:”2″,”suma_zakazky”:”5760″,”suma_rp”:”0″,”aktualizacia”:”2018-05-18 11:56:00″,”suma_zakazky_mesiac”:”50258″,”pocet_zakaziek_mesiac”:”16″,”suma_rp_mesiac”:”6216″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”5760″,”celkom_cashflow_mesiac_cz”:”85696″},{“celkom_cashflow”:”1000″,”prevadzka”:”58″,”celkom_cashflow_mesiac”:”111510″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”1000″,”aktualizacia”:”2018-05-18 11:49:00″,”suma_zakazky_mesiac”:”128033.91″,”pocet_zakaziek_mesiac”:”33″,”suma_rp_mesiac”:”8091″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”1000″,”celkom_cashflow_mesiac_cz”:”111510″},{“celkom_cashflow”:”2668″,”prevadzka”:”59″,”celkom_cashflow_mesiac”:”238173″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”1668″,”aktualizacia”:”2018-05-18 11:42:00″,”suma_zakazky_mesiac”:”238428.24″,”pocet_zakaziek_mesiac”:”53″,”suma_rp_mesiac”:”20314″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”2668″,”celkom_cashflow_mesiac_cz”:”238173″},{“celkom_cashflow”:”849″,”prevadzka”:”60″,”celkom_cashflow_mesiac”:”76858″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”849″,”aktualizacia”:”2018-05-18 11:44:00″,”suma_zakazky_mesiac”:”77178″,”pocet_zakaziek_mesiac”:”19″,”suma_rp_mesiac”:”12668″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”849″,”celkom_cashflow_mesiac_cz”:”76858″},{“celkom_cashflow”:”0″,”prevadzka”:”61″,”celkom_cashflow_mesiac”:”61948″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”0000-00-00 00:00:00″,”suma_zakazky_mesiac”:”47549.4″,”pocet_zakaziek_mesiac”:”11″,”suma_rp_mesiac”:”3507″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”61948″},{“celkom_cashflow”:”2317″,”prevadzka”:”62″,”celkom_cashflow_mesiac”:”47543″,”pocet_zakaziek”:”1″,”suma_zakazky”:”2390″,”suma_rp”:”299″,”aktualizacia”:”2018-05-18 11:55:00″,”suma_zakazky_mesiac”:”46173″,”pocet_zakaziek_mesiac”:”14″,”suma_rp_mesiac”:”5302″,”ico”:”27251349″,”krajina”:”cz”,”celkom_cashflow_cz”:”2317″,”celkom_cashflow_mesiac_cz”:”47543″},{“celkom_cashflow”:”8230″,”prevadzka”:”81″,”celkom_cashflow_mesiac”:”132523″,”pocet_zakaziek”:”4″,”suma_zakazky”:”11278″,”suma_rp”:”25″,”aktualizacia”:”2018-05-18 11:53:00″,”suma_zakazky_mesiac”:”133137.4″,”pocet_zakaziek_mesiac”:”41″,”suma_rp_mesiac”:”7644.12″,”ico”:”27447839″,”krajina”:”cz”,”celkom_cashflow_cz”:”8230″,”celkom_cashflow_mesiac_cz”:”132523″},{“celkom_cashflow”:”3208″,”prevadzka”:”91″,”celkom_cashflow_mesiac”:”91301″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”1690″,”aktualizacia”:”2018-05-18 11:54:00″,”suma_zakazky_mesiac”:”79398.8″,”pocet_zakaziek_mesiac”:”33″,”suma_rp_mesiac”:”9168″,”ico”:”04956958″,”krajina”:”cz”,”celkom_cashflow_cz”:”3208″,”celkom_cashflow_mesiac_cz”:”91301″},{“celkom_cashflow”:”0″,”prevadzka”:”92″,”celkom_cashflow_mesiac”:”5176″,”pocet_zakaziek”:”0″,”suma_zakazky”:”0″,”suma_rp”:”0″,”aktualizacia”:”0000-00-00 00:00:00″,”suma_zakazky_mesiac”:”0″,”pocet_zakaziek_mesiac”:”0″,”suma_rp_mesiac”:”3643″,”ico”:”04956958″,”krajina”:”cz”,”celkom_cashflow_cz”:”0″,”celkom_cashflow_mesiac_cz”:”5176″}]

    • Consider using Retrofit to make the network calls and seriablize the JSON.

  • Anonymous

    Bro shouldn’t we using sockets for this
    In web client and server communicate through sockets right eg when we request for a web page sockets are involved isn’t it the same way in android
    Could you please help me out

    • Sockets are used for Realtime communications. For a simple screen loading HTTP call is enough.