简体   繁体   中英

JSON unexpected token error (PHP json_encode & jsonlint.com)

{"cover":"http:\/\/files.domain.com\/some_file\/1234.jpg_thumb.png"}

This is my JSON code and when I tries to parse, it returns Unexpected Token error. I checked on http://jsonlint.com/ but it didn't go well.

I used php json_encode function to encode JSON.

++ update It works fine when I copy JSON string and paste it in Notepad or other plain text editors and re-copy that. I think it must be some encoding error or something. I'll try.

I Fixed it. It was very simple to find out; I captured packet and view hex, and there's other byte in json. My php file encoding was UTF-8 with BOM! I simply converted it to utf-8 without bom, and all is well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM