title: decoding the JSON output from Microsoft translator API with PHP
body: <p><strong>this issue seems specific to microsofttranslator.com</strong> so please ... any answers, if you can test against it ... </p>
  
  <p>Using the following URL for translation:  <a href="http://api.microsofttranslator.com/V2/Ajax.svc/TranslateArray" rel="nofollow">http://api.microsofttranslator.com/V2/Ajax.svc/TranslateArray</a> .. I send via cURL some fantastic arguments, and get back the following result:</p>
  
  <pre><code> [
        {
             "From":"en",
             "OriginalTextSentenceLengths":[13],
             "TranslatedText":"我是最好的",
             "TranslatedTextSentenceLengths":[5]
        },
        {
             "From":"en",
             "OriginalTextSentenceLengths":[16],
             "TranslatedText":"你是最好的",
             "TranslatedTextSentenceLengths":[5]
        }
   ]
  </code></pre>
  
  <p>When I use <code>json_decode($output, true);</code> on the output from cURL, json_decode gives an error about the syntax not being appropriate in the returned <strong>JSON</strong>:</p>
  
  <pre><code> json_last_error() == JSON_ERROR_SYNTAX
  </code></pre>
  
  <p>The headers being returned with the JSON:</p>
  
  <blockquote>
    <p>Response Headers</p>
  </blockquote>
  
  <pre><code> Cache-Control:no-cache
   Content-Length:244
   Content-Type:application/x-javascript; charset=utf-8
   Date:Sat, 06 Aug 2011 13:35:08 GMT
   Expires:-1
   Pragma:no-cache
   X-MS-Trans-Info:s=63644
  </code></pre>
  
  <blockquote>
    <p>Raw content:</p>
  </blockquote>
  
  <pre><code> [{"From":"en","OriginalTextSentenceLengths":[13],"TranslatedText":"我是最好的","TranslatedTextSentenceLengths":[5]},{"From":"en","OriginalTextSentenceLengths":[16],"TranslatedText":"你是最好的","TranslatedTextSentenceLengths":[5]}]
  </code></pre>
  
  <blockquote>
    <p>cURL code:</p>
  </blockquote>
  
  <pre><code>    $texts = array("i am the best" =&gt; 0, "you are the best" =&gt; 0);
      $ch = curl_init(); 
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      $data = array(
          'appId' =&gt; $bing_appId,
          'from' =&gt; 'en',
          'to' =&gt; 'zh-CHS',
          'texts' =&gt; json_encode(array_keys($texts))
      );
      curl_setopt($ch, CURLOPT_URL, $bingArrayUrl . '?' . http_build_query($data)); 
      $output = curl_exec($ch); 
  </code></pre>