title: Creating JSONObject from string in JAVA (org.json)
body: <p>I'm using the org.json and I have that JSON in a string: </p>
  
  <blockquote>
    <p>{"hours":["1","2","3","4","5","6","7","8","9","10","11"]}</p>
  </blockquote>
  
  <p>When I try to create a new JSONObject from that string, I'm getting the following error:</p>
  
  <pre><code>Value of type ..String cannot be converted to JSONObject.
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> assuming str has the content:</p>
  
  <pre><code>JSONObject jObject = new JSONObject(str);
  </code></pre>
  
  <p><strong>EDIT2:</strong> Here's the real string:</p>
  
  <pre><code>{"hours":["1","2","3","4","5","6","7","8","9","10","11"],"lessons":["\u05d2\u05d9\u05d0,\u05ea\u05dc\u05de,\u05e2\u05e8\u05d1,\u05e4\u05d9\u05e1,\u05d1\u05d9\u05d5,\n\u05d6\u05d9\u05d5,\u05d5\u05d9\u05d9,\u05dc\u05d5\u05d9,\u05e4\u05d1\u05dc,\u05e8\u05d9\u05d9,","\u05d2\u05d9\u05d0,\u05ea\u05dc\u05de,\u05e2\u05e8\u05d1,\u05e4\u05d9\u05e1,\u05d1\u05d9\u05d5,\n\u05d6\u05d9\u05d5,\u05d5\u05d9\u05d9,\u05dc\u05d5\u05d9,\u05e4\u05d1\u05dc,\u05e8\u05d9\u05d9,","\u05d7\u05e0\"\u05d2 \u05d1\u05e0\u05d9\u05dd,\u05d7\u05e0\"\u05d2 \u05d1\u05e0\u05d5\u05ea\n\u05d9\u05de\u05e4\u05d5\u05dc\u05e1\u05e7\u05d9 \u05dc,\u05e0\u05d0\u05d5\u05e8 \u05de\u05dc\u05d9","\u05e1\u05e4\u05e8\u05d5\u05ea\n\u05d6\u05d9\u05dc\u05d3\u05de\u05df \u05d0\u05d5\u05e8\u05dc\u05d9","\u05d0\u05e0\u05d2\u05dc\u05d9\u05ea\n\u05d1\u05e9\u05d9 \u05e9\u05d5\u05dc\u05de\u05d9\u05ea","\u05d0\u05e0\u05d2\u05dc\u05d9\u05ea\n\u05d1\u05e9\u05d9 \u05e9\u05d5\u05dc\u05de\u05d9\u05ea","\u05ea\u05e0\",\u05e2\u05e8\u05d1,\u05e6\u05e8\u05e4,\u05e7\u05d5\u05dc,\u05d1\u05d9\u05d5,\n\u05e9\u05d7\u05e3,\u05de\u05d6\u05dc,\u05dc\u05e1\u05e7,\u05d8\u05d5\u05e4,\u05dc\u05d5\u05d9,","\u05ea\u05e0\",\u05e2\u05e8\u05d1,\u05e6\u05e8\u05e4,\u05e7\u05d5\u05dc,\u05d1\u05d9\u05d5,\n\u05e9\u05d7\u05e3,\u05de\u05d6\u05dc,\u05dc\u05e1\u05e7,\u05d8\u05d5\u05e4,\u05dc\u05d5\u05d9,","\u05e2\u05e8\u05d1,\u05e7\u05d5\u05dc,\u05d1\u05d9\u05d5,\u05d8\u05db\",\u05e8\u05d5\u05e1,\n\u05dc\u05d5\u05d9,\u05e7\u05de\u05d7,\u05d1\u05e1\u05d5,\u05d5\u05e7\u05e1,\u05e6\u05d5\u05e8,","\u05e2\u05e8\u05d1\u05d9,\u05e7\u05d5\u05dc\u05e0,\u05d1\u05d9\u05d5\u05d8,\u05d8\u05db\"\u05dd\n\u05dc\u05d5\u05d9,\u05d1\u05e1\u05d5\u05df,\u05d5\u05e7\u05e1,\u05e6\u05d5\u05e8",""]}
  </code></pre>
  
  <p><strong>EDIT3:</strong> Finally, here's my code, hopefully you can fix that problem.</p>
  
  <pre><code>StringBuilder str = new StringBuilder();
          TextView textView = new TextView(this);
          HttpClient client = new DefaultHttpClient();
          HttpGet request = new HttpGet("http://ohel-shem.com/~iApplication/appdata.php?pass=12345&amp;request=cp&amp;day=4%20&amp;class=7&amp;layer=12");
          Log.d("MyTag","Before");
          HttpResponse response = client.execute(request);
  
  //       Get the response
          BufferedReader rd = new BufferedReader
            (new InputStreamReader(response.getEntity().getContent()));
  
          String line = "";
          while ((line = rd.readLine()) != null) {
            str.append(line);
          } 
          Log.d("MyTag","hello");
          String s = str.toString();
                  s= s.replaceAll("\n", "\\n");
                  JSONObject json = new JSONObject(s); //Occures an error converting string to jsonobject
  </code></pre>