I am trying to return json content read from MySQL server. It should be easy, but there is a “strange” character that continues to appear at the beginning of the content.
I have two pages for returning content:
I tried to check it here jsonformatter.curiousconcept.com , but only page 1 is checked, page 2 says that it does not contain JSON data.
When accessing directly, both pages have no problems. Then what is the difference, why are both not checked?
Then I found this jsonformat.com page and tried the same thing. Page 1 was fine and page 2 was not, but, surprisingly, the data could be read. At first sight,
{"a":"b"}
may look good, but the character is ahead.
According to the online hex editor, this line value is higher (instead of 9 values, 10):
-- 7B 22 61 22 3A 22 62 22 7D
Echo json code on page 2:
header("Content-Type: application/json");
echo "{\"a\":\"b\"}";
source
share