title: Android Converting String to JSON
body: <p>I need advice into how to work out a method in Android which has to pick a string loaded with JSON data and then convert it back to JSON.</p>
  
  <p>For the time being, I have programmed the following but I'm not sure if I'm on the right track or not.</p>
  
  <pre><code>private void convert_JSON()
      {
      String json;
      //funcions per a cridar el string amb JSON i convertir-lo de nou a JSON
      JSONArray jsas = new JSONArray(); 
      for (int i =0; i &lt; jsas.length(); i++)
      {
          JSONObject message = jsas.getJSONObject(i);
          String content = message.getString("content");
      }
  
      }
  </code></pre>
  
  <p>The JSON is loaded into a String in this other method:</p>
  
  <pre><code>private void read_JSON(String json)
      {
  
          JSONObject jObject = new JSONObject(json);
          JSONArray jso3 = new JSONArray (jObject.getString("Nombres_Hijos"));
          String name = jso3.getString("Nombre");
          System.out.println(name);
  
          String surname = jso3.getString("Apellidos");
          System.out.println(surname);
  
          int date = jso3.getInt("Año_nacimiento");
          System.out.println(date);
  
          JSONArray jsa2 = jso3.getJSONArray ("Nombres_Hijos");
          String names = jsa2.toString();
          for (int i=0; i &lt; jsa2.length(); i++)
          {
              System.out.println(jsa2.getString(i));  
          }
          jso3.toString(json);
      }
  </code></pre>
  
  <p>And, lastly, the JSON is created within the MainActivity.java, not as a split file yet that does work correctly:</p>
  
  <pre><code>private void create_JSON(String json)
      {
          JSONObject jso = new JSONObject();
  
          try {
              jso.put("Nombre","Miguel");
              jso.put("Apellidos", "Garcia");
              jso.put("Año_nacimiento", 1990);
              JSONArray jsa = new JSONArray();
              jsa.put("Blur");
              jsa.put("Clur");
              jso.put("Nombres_Hijos", jsa);
  
          } catch (JSONException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          return jso.toString();
  </code></pre>
  
  <p>In short: what I want to know is if my method convert_JSON is on the right track or I'm misunderstanding how it's supposed to work like.</p>
  
  <p>Thank you very much for your help.</p>
  
  <p>Yours sincerely,</p>
  
  <p>Mauro.</p>