saapby / json-simple

Automatically exported from code.google.com/p/json-simple
0 stars 0 forks source link

JSONParser.parse not working for UTF-8 encoded file #88

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a json file with utf-8 encoding in any text editor (I used Notepad++)

2. parser.parse(new BufferedReader(new InputStreamReader(new 
FileInputStream(fileName), "UTF8"))); 

3. Always giving error : Unexpected character () at position 0.

What is the expected output? What do you see instead?
It should give a parsed JSONObject

What version of the product are you using? On what operating system?
json-simple-1.11.jar on Windows-7

Please provide any additional information below.

Original issue reported on code.google.com by grvmerat...@gmail.com on 30 Jul 2013 at 1:59

GoogleCodeExporter commented 8 years ago
Could you attach the JSON file?

Original comment by fangyid...@gmail.com on 30 Jul 2013 at 3:41

GoogleCodeExporter commented 8 years ago
attached is input file. File is created using Notepad++ with UTF-8 encoding
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("D:/emp.txt"));
it is giving error
Unexpected character (ï) at position 0.

Original comment by grvmerat...@gmail.com on 31 Jul 2013 at 11:43

Attachments:

GoogleCodeExporter commented 8 years ago
You may have an incorrect UTF-8 BOM in your file.I am attaching the correct 
file format. You may want to compare these 2 files in hex mode.

Original comment by fangyid...@gmail.com on 8 Aug 2013 at 11:36

Attachments:

GoogleCodeExporter commented 8 years ago
Additional note: this is caused by the additional BOM (EF BB BF) in the 
beginning.Please un-check the "BOM" option (if any) when you save your file.

Original comment by fangyid...@gmail.com on 8 Aug 2013 at 11:48