Parsing Json Data in Android Studio - cannot display all data in logs
<p>So basically I am developing an app which retrieves data from mysql database. Therefore I have created a php script which retrieves data from database and outputs  data in JSON format:</p>

<pre><code>{
    "newslog": [
        {
            "Id": "1",
            "Title": "News Item 1",
            "Author": "Nich",
            "Body": "aldfjlak dklflksd afkjdflk ",
            "Date": "2016-07-26"
        },
        {
            "Id": "2",
            "Title": "News Item 2",
            "Author": "nich",
            "Body": "la la la la la la",
            "Date": "2016-07-26"
        },
        {
            "Id": "3",
            "Title": "News Item 3",
            "Author": "nich",
            "Body": "oh oh oh oh oh",
            "Date": "2016-07-26"
        }
    ]
}
</code></pre>

<p>I am using Android Studio, and managed to display this data (in JSON format) in Android Studio logs, as shown below: </p>

<p><a href="https://i.stack.imgur.com/xl4Em.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xl4Em.png" alt="enter image description here"></a></p>

<p><strong>Problem</strong>:</p>

<p>I would like to display parts from this data (JSON) in the logs. However at the moment I can only display in the logs the "Title".  When I try to retrieve the "Id", "Body" or "Date" they seem to be ignored.  I am sure that I am missing something.</p>

<p><strong>Code used to output data in logs:</strong></p>

<p><a href="https://i.stack.imgur.com/kfKTs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfKTs.png" alt="Code used to output data in logs"></a> </p>

<p><strong>Logs:</strong></p>

<p><a href="https://i.stack.imgur.com/LlFjM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LlFjM.png" alt="enter image description here"></a></p>

<p><strong>Android Studio code:</strong></p>

<pre><code>import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.widget.ListView;

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

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


public class NewsActivity extends AppCompatActivity {

    private ListView lv;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        lv = (ListView) findViewById(R.id.listView);


//       List&lt;String&gt; newsItems = new ArrayList&lt;String&gt;();
//       newsItems.add("News 1");
//       newsItems.add("News 2");
//
//
//      ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, newsItems);
//       lv.setAdapter(arrayAdapter);

        DownloadTask task = new DownloadTask();
        task.execute("http://council4u.com/php-scripts/getnews.php");
    }

    public class DownloadTask extends AsyncTask&lt;String, Void, String&gt;{

        @Override
        protected String doInBackground(String... urls) {

            String result = "";
            URL url;
            HttpURLConnection urlConnection = null;

            try {
                url = new URL(urls[0]);

                urlConnection = (HttpURLConnection) url.openConnection();

                InputStream in = urlConnection.getInputStream();

                InputStreamReader reader = new InputStreamReader(in);

                int data = reader.read();

                while (data != -1) {

                    char current = (char) data;

                    result += current;

                    data = reader.read();
                }

                return result;

            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }


            return null;
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);

            try{
                JSONObject data = new JSONObject(result);

                String latestnews = data.getString("newslog");
               Log.i ("Latest News", latestnews);


                JSONArray arr = new JSONArray(latestnews);

                for (int i = 0; i &lt; arr.length(); i++) {

                    JSONObject jsonPart = arr.getJSONObject(i);


                    Log.i("title", jsonPart.getString("Title"));
                    Log.i("Body", jsonPart.getString("Body"));

                }

            }  catch (JSONException e) {
                e.printStackTrace();
            }


        }}
}
</code></pre>