title: How to Pretty-Print , JSON raw datas on Android
body: <p>I have an API in JSON , my json datas are displayed raw on my android application , i want them to be displayed in pretty print format like this</p>
  <p><a href="https://i.stack.imgur.com/hJSe3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hJSe3.png" alt="Pretty JSON Data" /></a></p>
  <p>Not like this</p>
  <p><a href="https://i.stack.imgur.com/kLH9l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kLH9l.png" alt="JSON Raw display on Android" /></a></p>
  <p>This is my java code :</p>
  <pre><code>package com.example.cbmedandroid;
  import java.io.IOException;
  import java.io.InputStream;
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.protocol.BasicHttpContext;
  import org.apache.http.protocol.HttpContext;
  import android.app.Activity;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  public class MainActivity extends Activity implements OnClickListener {
  @Override
  
  
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  
  
  findViewById(R.id.my_button).setOnClickListener(this);
  }
  
  
  @Override
  
  
  public void onClick(View arg0) {
  Button b = (Button)findViewById(R.id.my_button);
  
  
  b.setClickable(false);
  new LongRunningGetIO().execute();
  }
  
  private class LongRunningGetIO extends AsyncTask &lt;Void, Void, String&gt; {
  protected String getASCIIContentFromEntity(HttpEntity entity) throws    IllegalStateException, IOException {
  InputStream in = entity.getContent();
  
  
  StringBuffer out = new StringBuffer();
  int n = 1;
  while (n&gt;0) {
  byte[] b = new byte[4096];
  n =  in.read(b);
  
  
  if (n&gt;0) out.append(new String(b, 0, n));
  }
  
  
  return out.toString();
  }
  
  
  @Override
  
  
  protected String doInBackground(Void... params) {
  HttpClient httpClient = new DefaultHttpClient();
  HttpContext localContext = new BasicHttpContext();
  HttpGet httpGet = new HttpGet(&quot;http://10.0.2.2:8000/api/horaire.json&quot;);
  String text = null;
  try {
  HttpResponse response = httpClient.execute(httpGet, localContext);
  
  
  HttpEntity entity = response.getEntity();
  
  
  text = getASCIIContentFromEntity(entity);
  
  
  } catch (Exception e) {
  return e.getLocalizedMessage();
  }
  
  
  return text;
  }
  
  
  protected void onPostExecute(String results) {
  if (results!=null) {
  EditText et = (EditText)findViewById(R.id.my_edit);
  
  
  et.setText(results);
  
  
  }
  
  
  Button b = (Button)findViewById(R.id.my_button);
  
  
  b.setClickable(true);
  }
  
  
  }
  }
  </code></pre>
  <p>How to do that ?</p>
  <p>Thanks</p>