After adding PHP header("Content-type: text/plain"); a space is added.
I use it for pretty JSON.
I need this:
{
"code":"200" }
}
But I get this:
{
"code":"200" }
}
Look at your PHP page closely, you probably just have whitespace in it (outside of your PHP tags) that you don't realize. (And you have an extra } in your JSON...)
<?php is first thing in your php file and remove ?>.<?php ... ?> blocks is sent to the client. So you need to make sure there are no characters outside of those blocks. At all.If you're using PHP 5.4 or greater you can use JSON_PRETTY_PRINT flag.
However I also think that you might have a whitespace before the print, if not in your main page, maybe in functions.php.
<?php ... ?>tags are, we need to see the full page (as you clearly have a nice, self-contained example there).{... is that what the source of concern is? Also - do you realize that what you've put out here is invalid JSON to begin with?