title: Get Array list with JSON in android studio
body: <p>I have a problem that bothers me for several hours.</p>
  
  <p>I have a dialog that is based on notifying if there is a new version of the application where it shows me a message with the available version along with the changes in it.</p>
  
  <p><strong>I have this code:</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
  private static  String url = "localhost/version.json";
  String VersionUpdate;
  String Cambios;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      new VersionCheck().execute();
  }
  private class VersionCheck extends AsyncTask&lt;Void, Void, Void&gt; {
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
      }
      @Override
      protected Void doInBackground(Void... arg0) {
          HttpHandler sh = new HttpHandler();
          String jsonStr = sh.makeServiceCall(url);
          if (jsonStr != null){
              try {
  
                  JSONObject jsonObj = new JSONObject(jsonStr);
                      JSONArray obtener = jsonObj.getJSONArray("Obtener");
                  for (int i = 0; i &lt; obtener.length(); i++)
                  {
                      JSONObject v = obtener.getJSONObject(i);
                      VersionUpdate = v.getString("version");
                      Cambios = v.getString("cambios");
                  }
              }catch (final JSONException e) {
  
                  // Log.e(TAG, "Json parsing error: " + e.getMessage());
                  runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
  
                          Toast.makeText(getApplicationContext(),
                                  "El formato de JSON esta errado: " + 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(),
                              "El servidor de comprobar versión esta caido.",
                              Toast.LENGTH_LONG)
                              .show();
                  }
              });
  
          }
          return null;
      }
  
          @Override
          protected void onPostExecute (Void result){
  
          if (VersionUpdate != null) {
  
          super.onPostExecute(result);
          String VersionName = BuildConfig.VERSION_NAME;
          if (VersionUpdate.equals(VersionName)) {
              Toast.makeText(getApplicationContext(),
                      "Version actual: " + VersionName,
                      Toast.LENGTH_LONG)
                      .show();
          } else {
  
              AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
              builder.setTitle("Actualización");
              builder.setIcon(R.mipmap.ic_launcher);
              builder.setMessage("Nueva versión disponible" + "\n" + "Incluye: " + Cambios + "\n" + "Version disponible: " + VersionUpdate)
                      .setPositiveButton("UPDATE", new DialogInterface.OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
  
                              final String appName = getPackageName();
  
                              try {
                                  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appName)));
                              } catch (android.content.ActivityNotFoundException anfe) {
                                  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appName)));
                              }
  
                              finish();
  
                          }
                      });
  
              AlertDialog alert = builder.create();
              alert.show();
  
  
              }
          }
      }
   }
  }
  </code></pre>
  
  <p><strong>And I have the JSON format on a web to read it, this would be:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>{
  "Obtener": [
     {
     "version": "1.2",
    "cambios": [ 
      "fox1",
      "fox2",
      "fox3",
      "fox4",
      "fox5",
      "fox6",
      "fox7",
      "fox8",
      "fox9",
      "fox10"
      ]
       }
   ] 
  } </code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>Everything is going well!</strong> however there is a json reading that is not appropriate and he sends me this message like this:</p>
  
  <p><a href="https://i.stack.imgur.com/agssN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/agssN.png" alt="enter image description here"></a></p>
  
  <p>My goal is to print the list <strong>"cambios"</strong> line by line without characters, example:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Nueva version disponible
  Incluye:
  Fox1
  Fox2
  Fox3
  Fox4
  Fox5
  Fox6
  Fox7
  Fox8
  Fox9
  Fox10
  Versión disponible: 1.2</code></pre>
  </div>
  </div>
  </p>
  
  <p>Kind regards, and thanks in advance for your answers :D.</p>