-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
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
[QUESTION] 有个 writerProvider.register 相关的代码没生效,疑惑! #1893
Comments
noear
changed the title
[QUESTION] 有个代码没生效,疑惑!
[QUESTION] 有个 writerProvider.register 相关的代码没生效,疑惑!
Sep 23, 2023
现在Long类型不支持自定义序列化 |
@wenshao 说出来你可能不信。我自己也晕。。。我在 solon 里的 fastjson2 适配,其特性 longAsString ,就是通过它实现的。。。但是我想写个小 demo 复现一个问题,却完全没效果。(就是关于那个 WriteNullNumberAsZero 后,没有变成 string 的问题)。。。这事儿,晕了我很久很久 |
https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.42-SNAPSHOT/ @Test
public void test() throws Exception {
assertEquals(
"{\"value\":\"0\"}",
JSON.toJSONString(new Bean(),
JSONWriter.Feature.WriteNullNumberAsZero,
JSONWriter.Feature.WriteLongAsString)
);
}
public static class Bean {
public Long value;
} |
@wenshao 好,明天我试下 |
@wenshao 测试了。有效! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
像下面这个代码,为什么没有打印出:
{"a":0,"b":0,"c":"1"}
The text was updated successfully, but these errors were encountered: