title: JSON Object creation is failing
body: <p>I have json file which i down from internet and saved to my app. Then i read this file and create json object . But i am not able to create json object .
   This is the exception I am getting </p>
  
  <p>org.json.JSONException: Expected literal value at character 3 of { \"resources\": { ..........</p>
  
  <p>Below is my code to read input stream and create json object</p>
  
  <pre><code> private JSONObject readFileFromInpputStream(InputStream inst) throws JSONException
      {
          // TODO Auto-generated method stub
          StringBuilder responseStrBuilder=null;
          try { 
              BufferedReader streamReader = new BufferedReader(new InputStreamReader(inst, "UTF-8")); 
              responseStrBuilder = new StringBuilder();
  
              String inputStr;
              while ((inputStr = streamReader.readLine()) != null){
                  responseStrBuilder.append(inputStr);  
              }
          }
          catch (UnsupportedEncodingException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          String str = responseStrBuilder.toString();
          String k=str.replace("\"", "\\\"");
         // String m =k.replaceAll("\t", "");
         // String s= m.replaceAll("\n", "");
          //String p = s.replaceAll("\\s", "");
          Log.i(loggerName, loggerName + " str " +str);
          //Log.i(loggerName, loggerName + " k " +p);
          JSONObject obj = new JSONObject(k);
          return obj;
      }
  </code></pre>
  
  <p>Below is output string </p>
  
  <pre><code>   {
      "resources": {
          "-xmlns:xliff": "urn:oasis:names:tc:xliff:document:1.2",
          "string": [
              {
                  "name": "sample1",
                  "value": "To &lt;xliff:g id=\"receiver_name\"&gt; Europe &lt;/xliff:g&gt;"
              },
              {
                  "name": "cdata",
                  "value": "&lt;![CDATA[&lt;p&gt;Text&lt;p&gt;]]&gt;"
              },
              {
                  "name": "content_description_sample",
                  "value": " &lt;b&gt;Something&lt;/b&gt;"
              },
              {
                  "name": "countdown",
                  "value": " &lt;xliff:g id="time" example="5days"&gt;%1$s&lt;/xliff:g&gt; until holiday"
              },
              {
                  "name": "picker_combined_view_fmt",
                  "value": " Combined view (&lt;xliff:g id="count"&gt;%s&lt;/xliff:g&gt;)"
              },
              {
                  "name": "configure_email_text",
                  "value": "No corporate email accounts have been configured on this device. To configure them, click &lt;b&gt;Here&lt;/b&gt; "
              },
              {
                  "name": "invalid_credentials",
                  "value": "Authentication failed. Enter valid credentials."
              },
              {
                  "name": "link",
                  "value": "&lt;b&gt;Hello World&lt;/b&gt; This is a test of the URL &lt;a href=\"http://www.example.com/\"&gt;Example&lt;/a&gt;"
              },
              {
                  "name": "bold",
                  "value": "&lt;b&gt;This text is bold&lt;/b&gt;"
              },
              {
                  "name": "emphasis",
                  "value": "&lt;em&gt;This text is emphasized&lt;/em&gt;"
              },
              {
                  "name": "check_availability_button",
                  "value": "Check availability How are you"
              }
          ],
          "string-array": [
              {
                  "name": "Array1",
                  "item": [
                      "en_US",
                      "en_GB"
                  ]
              },
              {
                  "name": "Array2",
                  "item": [
                      "en_US",
                      "en_GB"
                  ]
              }
          ]
      }
  }{
      \"resources\": {
          \"-xmlns: xliff\": \"urn: oasis: names: tc: xliff: document: 1.2\",
          \"string\": [
              {
                  \"name\": \"sample1\",
                  \"value\": \"To&lt;xliff: gid=\\"receiver_name\\"&gt;Europe&lt;/xliff: g&gt;\"
              },
              {
                  \"name\": \"cdata\",
                  \"value\": \"&lt;![
                      CDATA[
                          &lt;p&gt;Text&lt;p&gt;
                      ]
                  ]&gt;\"
              },
              {
                  \"name\": \"content_description_sample\",
                  \"value\": \"&lt;b&gt;Something&lt;/b&gt;\"
              },
              {
                  \"name\": \"countdown\",
                  \"value\": \"&lt;xliff: gid=\"time\"example=\"5days\"&gt;%1$s&lt;/xliff: g&gt;untilholiday\"
              },
              {
                  \"name\": \"picker_combined_view_fmt\",
                  \"value\": \"Combinedview(&lt;xliff: gid=\"count\"&gt;%s&lt;/xliff: g&gt;)\"
              },
              {
                  \"name\": \"configure_email_text\",
                  \"value\": \"Nocorporateemailaccountshavebeenconfiguredonthisdevice.Toconfigurethem,
                  click&lt;b&gt;Here&lt;/b&gt;\"
              },
              {
                  \"name\": \"invalid_credentials\",
                  \"value\": \"Authenticationfailed.Entervalidcredentials.\"
              },
              {
                  \"name\": \"link\",
                  \"value\": \"&lt;b&gt;HelloWorld&lt;/b&gt;ThisisatestoftheURL&lt;ahref=\\"http: //www.example.com/\\"&gt;Example&lt;/a&gt;\"
              },
              {
                  \"name\": \"bold\",
                  \"value\": \"&lt;b&gt;Thistextisbold&lt;/b&gt;\"
              },
              {
                  \"name\": \"emphasis\",
                  \"value\": \"&lt;em&gt;Thistextisemphasized&lt;/em&gt;\"
              },
              {
                  \"name\": \"check_availability_button\",
                  \"value\": \"CheckavailabilityHowareyou\"
              }
          ],
          \"string-array\": [
              {
                  \"name\": \"Array1\",
                  \"item\": [
                      \"en_US\",
                      \"en_GB\"
                  ]
              },
              {
                  \"name\": \"Array2\",
                  \"item\": [
                      \"en_US\",
                      \"en_GB\"
                  ]
              }
          ]
      }
  }
  </code></pre>
  
  <p>and below is the exception i am getting </p>
  
  <pre><code>org.json.JSONException: Expected literal value at character 3 of {  \"resources\": { ..........
  </code></pre>
  
  <p>What am I doing wrong?</p>