Loading the JSON file today is not successful, only ASCII encoded format can be loaded, because it is Chinese, so it can not be used in ASCII format, later my colleague found that the first character of the JSON encoding is 65279, and then Baidu a bit, because I edited this JSON file with text So that it has a BOM header.
The solution on the web is to use software such as EditPlus or UltraEdit to save as UTF-8, as follows:
1. Use EditPlus to remove BOM head
After the editor is resized to UTF8 encoded format, the saved file will be preceded by a string of hidden characters (also known as BOMs), used by the editor to identify whether the file is encoded in UTF8.
Run EditPlus, click Tools, select Preferences, select files, UTF-8 identity Select always delete signatures, and then edit and save php files without BOM.
2. Use UltraEdit to remove BOM head
After opening the file, select the "Save as" option in the encoding format (UTF-8 no BOM header), OK.
However, my colleague's method is to read the JSON to determine whether the first encoding is 65279, and then delete the character encoding
if ((int) (json[0]) = = 65279) { JSON = json. Substring (1);}
Read JSON, the beginning of file 65279 is not recognized