We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
类似 #2543,fastjson和fastjson2在JSON.toJSONBytes后进行序列化的结果不一致,而且均不符合正常预期。
import com.alibaba.fastjson2.JSON; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; public class Issue2128Mutated_25 { @Test public void test() { String str = "{\"amt\":22.12}"; System.out.println(com.alibaba.fastjson.JSON.toJSONString(com.alibaba.fastjson.JSON.parseObject(str))); assertEquals(com.alibaba.fastjson.JSON.toJSONString(com.alibaba.fastjson.JSON.parseObject(str)), JSON.toJSONString(JSON.parseObject(str))); assertEquals(com.alibaba.fastjson.JSON.toJSONString(com.alibaba.fastjson.JSON.toJSONBytes(str)), JSON.toJSONString(JSON.toJSONBytes(str))); } }
toJSONBytes后序列化行为应一致,且结果正确
{"amt":22.12}
org.opentest4j.AssertionFailedError: Expected :"IntcImFtdFwiOjIyLjEyfSI=" Actual :[34,123,92,34,97,109,116,92,34,58,50,50,46,49,50,125,34]
The text was updated successfully, but these errors were encountered:
这个testcase构造得不对,JSON.toJSONBytes的作用类似于JSON.toJSONString().getBytes(StandardCharsets.UTF8)
Sorry, something went wrong.
No branches or pull requests
问题描述
类似 #2543,fastjson和fastjson2在JSON.toJSONBytes后进行序列化的结果不一致,而且均不符合正常预期。
环境信息
重现步骤
期待的正确结果
toJSONBytes后序列化行为应一致,且结果正确
相关日志输出
{"amt":22.12}
org.opentest4j.AssertionFailedError:
Expected :"IntcImFtdFwiOjIyLjEyfSI="
Actual :[34,123,92,34,97,109,116,92,34,58,50,50,46,49,50,125,34]
The text was updated successfully, but these errors were encountered: