Java Spring Jackson json库返回unicode而不是文本 [英] Java Spring Jackson json library returning unicode instead of text
问题描述
我正在使用本教程:
http://www.mkyong.com/spring-mvc/spring-3-mvc-and-json-example/
从我的Java Spring Web应用程序返回JSON。当我在对象中返回超过1000个字符的字符串时,字符将仅为该字符串值转换为\ u0000。该字符串在返回之前是正常的。
to return JSON from my Java Spring web application. When I return a String over 1000 characters in object, the characters are converted into \u0000 just for that String value. The string is fine before it is returned.
任何帮助将不胜感激。
推荐答案
这不是解决方案,但杰克逊提供的 UTF8JsonGenerator
是一个问题。如果字符串的长度大于1000个字符,则调用 _writeLongString(_charBuffer,0,len)
。变量 _charBuffer
只是一个4000字符的空缓冲区(其中的每个值都设置为\ u0000),所以你得到一个 len
- 多个字符串\ u0000。
It's not a solution but it's an issue with the UTF8JsonGenerator
that Jackson provides. If your string is > 1000 characters in length, it calls _writeLongString(_charBuffer, 0, len)
. The variable _charBuffer
is just a 4000 character null buffer (each value in it is set to "\u0000") so you get a len
-many character string of "\u0000".
编辑:升级过去的版本2.6.0-rc1应该是修复(通过 https://github.com/FasterXML/jackson-core/issues/194 )
Upgrading past version 2.6.0-rc1 should be the fix (via https://github.com/FasterXML/jackson-core/issues/194)
这篇关于Java Spring Jackson json库返回unicode而不是文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!