Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries
来源:互联网 发布:度量衡软件app 编辑:程序博客网 时间:2024/03/29 18:03
【问题】
从文件中读字符串内容,使用 org.codehaus.jackson.map.ObjectMapper。将json转java对象时,
异常:org.codehaus.jackson.JsonParseException: Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries
【原因】
异常:以逗号分隔对象...
检查源文件的json字符,json格式正确。
而是在读文件时,读出来的json字符串乱码,导致json格式错误
【解决】按照与文件相符的编码读取文件内容
public static String readFile(File file){ StringBuilder result = new StringBuilder(); try{ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8")); String s = null; while((s = br.readLine())!=null){ result.append(System.lineSeparator()+s); } br.close(); }catch(Exception e){ e.printStackTrace(); } return result.toString().replace("\r\n", ""); }
阅读全文
0 0
- Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries
- JsonParseException: Unexpected character ('?' (code 239)): was expecting comma to separate OBJECT en
- org.codehaus.jackson.JsonParseException: Unexpected character ('e' (code 101)): was expecting comma
- Go报错 : syntax error: unexpected string, expecting comma or )
- JsonParseException: Unexpected character ('?' (code 255))
- Object.entries()
- unexpected T_STRING expecting ',' or ';'
- was expecting double-quote to start field name错误
- Unexpected character ('<' (code 60)): expected a valid value ...
- why separate the source code of a codec into two p
- why separate the source code of a codec into two p
- Syntax error: word unexpected (expecting ")")
- Syntax error: word unexpected (expecting ")")
- Syntax error: word unexpected (expecting ")")
- syntax error, unexpected T_OBJECT_OPERATOR, expecting ')'
- 探索 ES8 Object.entries()
- Unexpected cast to TabLayout: layout tag was TableLayout
- Unexpected cast to TabLayout: layout tag was TableLayout
- caffe python layer
- Git与SVN,选哪个好?
- recyclerview No adapter attached; skipping layout
- ICMP隧道工具ptunnel
- 剖析并利用Visual Studio Code在Mac上编译、调试c#程序
- Unexpected character ('P' (code 80)): was expecting comma to separate OBJECT entries
- Spring AOP为什么不能拦截同一个对象内方法的嵌套调用
- 事件分发机制
- [转载] 编译型语言、解释型语言、静态类型语言、动态类型语言概念与区别
- C#线程同步的几种方法
- 从架构演进的角度聊聊Spring Cloud都做了些什么?
- 性能测试建设实践汇总
- UE4中UMG UI Navigation的源码分析
- lua math库