title: Trying to load json from assets in android studio
body: <p>Here is my code:</p>
  
  <pre><code>public String loadJSONFromAsset() {
      String json = null;
      try {
  
          InputStream is = getAssets().open("index.json");
  
          int size = is.available();
  
          byte[] buffer = new byte[size];
  
          is.read(buffer);
  
          is.close();
  
          json = new String(buffer, "UTF-8");
  
  
      } catch (IOException ex) {
          ex.printStackTrace();
          return null;
      }
      return json;
  
  }
  
  JSONObject object = new JSONObject(loadJSONFromAsset());
  </code></pre>
  
  <p>I get an error underlining the last row:</p>
  
  <pre><code>JSONObject object = new JSONObject(loadJSONFromAsset());
  </code></pre>
  
  <p>saying:</p>
  
  <blockquote>
    <p>Unhandled Exception org.json.JSONException</p>
  </blockquote>