位置0处的意外字符(ï)。使用sample-json-1.1.1使用java进行JSON解析

时间:2018-04-07 12:33:11

标签: json

我正在尝试解析使用java中的sample-json从ie11浏览器生成的Har文件,我得到“位置0处的意外字符(ï)” 并且相同的代码适用于从Chrome浏览器生成的Har文件。

以下是我正在使用的代码。

JSONParser jsoneParser = new JSONParser();
Object object ;
JSONObject  jsonObject = (JSONObject) jsoneParser.parse(new InputStreamReader(new FileInputStream("jsonfile.json"), StandardCharsets.UTF_8));

    Output:
    Unexpected character (?) at position 0.
        at org.json.simple.parser.Yylex.yylex(Yylex.java:610)
        at org.json.simple.parser.JSONParser.nextToken(JSONParser.java:269)
        at org.json.simple.parser.JSONParser.parse(JSONParser.java:118)
        at org.json.simple.parser.JSONParser.parse(JSONParser.java:92)
        at jsontojava.jsonreader.main(jsonreader.java:74)



Can some one pleases help with correct solution for this

1 个答案:

答案 0 :(得分:0)

而不是StandardCharsets.UTF_8使用StandardCharsets.ISO_8859_1。