title: json_ encode - JSON.parse() combination, work well in Firefox but fail in other browsers
body: <p>I'm using the combination of json_encode (PHP) and JSON.parser (Javascript from json.org) for passing a JSON object from PHP to Javascript, the JSON object may have quotes and double quotes so I'm using addslashes() function in PHP. This combination work well in Firefox but not in other browsers like Safari, Chrome or Internet Explorer. This is the code:</p>
  
  <pre><code>&lt;?php
  
     $json =array('n' =&gt; count($arrayEx), 'items' =&gt; array());
  
     foreach($arrayEx as $item)
     {
        $json['items'][]=array( 'property1' =&gt; addslashes($item['property1']),
                       'property2' =&gt;addslashes($item['property2'])
                              );
  
     }    
  
     $json_string = json_encode($json);
  
  ?&gt;
  
  &lt;script&gt;    
     var json_string= '&lt;? echo $json_string; ?&gt;'; 
     var json_object = JSON.parse(json_string);   //Fail in this line
  &lt;/script&gt;
  </code></pre>
  
  <p>Fail with error message "String literal not ended".</p>
  
  <p>Thanks</p>