title: JSON from restful web service
body: <p>I created a restful web service in php using the slim framework. One of the functions returns a dynamically created multidimensional array and encodes it as a JSON array like this</p>
  
  <pre><code>[{  
      "hid":100001,
      "SubTable":"grpsubs",
      "StatTable":"grpstats",
      "uid":2,
      "Status":"G"
  },
  {  
      "hid":100002,
      "SubTable":"gtmsubs",
      "StatTable":"gtmstats",
      "uid":2,
      "Status":"R"
  }]
  </code></pre>
  
  <p>In my android app I use the loopj framework to get the restful output like this</p>
  
  <pre><code>AsyncHttpClient client = new AsyncHttpClient();
  client.addHeader("Authorization", key);
  client.post("https://mythic-beanbag-106723.appspot.com/v1/mine", params, new AsyncHttpResponseHandler() {
      // When the response returned by REST has Http response code '200'
      @Override
      public void onSuccess(String response) {
          // Hide Progress Dialog
          hospDialog.hide();
          Log.e("Response", response);
          try {
  
              JSONArray array = new JSONArray(response);
              Log.e("array", String.valueOf(array.length()));
  
          } catch (JSONException e) {
              // TODO Auto-generated catch block
              Toast.makeText(getApplicationContext(), "Error Occurred [Server's JSON response might be invalid]!", Toast.LENGTH_LONG).show();
              e.printStackTrace();
  
          }
      }
  </code></pre>
  
  <p>Using the Advanced REST Client in chrome I can see the JSON however in my app when I try outputting the JSON in the console <code>Log.e("Response", response);</code> it shows up as an empty array <code>[]</code>. This code works for my Login function and in php if instead of using a dynamically created array I use a static array like <code>array("abc"=&gt;array("def"=&gt;"ghi"), "jkl"=&gt;array("mno"=&gt;"pqr"))</code> the above code does output the JSON array.</p>
  
  <p>UPDATE:</p>
  
  <p>params</p>
  
  <pre><code>RequestParams params = new RequestParams();
  params.put("uid", prefs.getInt("uid", 0));
  </code></pre>