Note that there are some explanatory texts on larger screens.

plurals
  1. POWeird JSON encoding using json_encode
    text
    copied!<p>I'm using WordPress together with the JSON API Plugin (http://wordpress.org/extend/plugins/json-api/) to generate responses to our other site.</p> <p>I've hit a really weird problem (we're using PHP 5.3.6), when I pass the following array <a href="http://pastebin.com/xdfYjrvK" rel="nofollow">http://pastebin.com/xdfYjrvK</a> to json_encode() it gives me this (with json content-type): <a href="http://pastebin.com/T61XGPP5" rel="nofollow">http://pastebin.com/T61XGPP5</a></p> <p>So the crap in the beginning, in the above example it's 2609 and 0 in the end, it changes depending on the size of the response, more content -> higher hex number. It also appears only when the amount of response is "high enough", so it works on small responses.</p> <p>First I thought it was the plugin, but it works locally (on two different machines Mac OS X) and we've updated all packages on the VPS (Debian, Apache, Nginx, PHP) to the latest versions.</p> <p>It's only displayed when sending the content-type, not when outputting the $result with plain text instead of application/json:</p> <pre><code>$charset = get_option('blog_charset'); if (!headers_sent()) { header('HTTP/1.1 200 OK', true); header("Content-Type: application/json; charset=$charset", true); } echo $result; </code></pre> <p>$charset is set to utf-8.</p> <p>The Google chrome console says: "Resource interpreted as Document but transferred with MIME type application/json."</p> <p>So, does anyone have a clue whats happening here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload