JSON generated by json_encode gives error in character "{"

2

I do not understand what's happening, I'm using a json_encode function in PHP and what does it return is invalid?!

I'm using jsonlint as the validator, and it states that the error is in the first { . If I replace this character with another { , it says it's valid. Am I using any incorrect encoding in the file? In my eyes the character looks exactly the same. The following is the return function:

{
   "status": 1,
   "page": "1",
   "content": "foo",
   "hasNext": true
}

There seems to be something wrong between this character - > {& lt ;-( copied) and that - > {

asked by anonymous 10.12.2014 / 18:51

1 answer

5

Everything indicates that your PHP is issuing something else before { . Make sure your file is saved as UTF-8 with BOM (byte-order mask), as BOM would invalidate JSON.

To check, open an editor like Notepad ++ and save the file as UTF-8 without BOM.

    
10.12.2014 / 19:03