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
以下为复现代码:
public class TestQuickConfig { @Test public void test(){ ObjectWriterProvider provider = new ObjectWriterProvider(); provider.register(Long.class, (out, obj, fieldName, fieldType, features) -> { String val = obj.toString(); out.writeString(val); }); JSONWriter.Context context = new JSONWriter.Context(provider, JSONWriter.Feature.WriteNullStringAsEmpty, JSONWriter.Feature.WriteNulls); DemoDo demoDo = new DemoDo(); String json = JSON.toJSONString(demoDo,context); System.out.println(json); //实际上 s1 输出为 null assert "{\"n0\":null,\"n1\":\"1\",\"s0\":\"\",\"s1\":\"noear\"}".equals(json); } @Getter @Setter public static class DemoDo implements Serializable { String s0; String s1 = "noear"; Long n0; Long n1 = 1L; //当有 Long 字段时,才触发这个问题 } }
The text was updated successfully, but these errors were encountered:
add testcase for issue #2642
fa90ad7
我用2.0.51-SNAPSHOT没有重现问题。你的功能也可以用JSONWriter.Feature.WriteLongAsString来实现啊
Sorry, something went wrong.
好晕啊。。。我重新拉了包,真的没错了。
这个 JSONWriter.Feature.WriteLongAsString 特性好,以前是不是没有的?
https://github.com/alibaba/fastjson2/releases/tag/2.0.51 请用新版本
ok
No branches or pull requests
以下为复现代码:
The text was updated successfully, but these errors were encountered: