You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class App {
public static class People {
private Integer age;
private Long hairNums;
private String name;
public People(Integer age, String name, Long hairNums) {
this.age = age;
this.name = name;
this.hairNums = hairNums;
}
public Integer getAge() {
return age;
}
public String getName() {
return name;
}
public Long getHairNums() {
return hairNums;
}
}
public static void main( String[] args )
{
SerializeConfig stringSerializeConfig = new SerializeConfig();
stringSerializeConfig.put(Integer.class, ToStringSerializer.instance);
stringSerializeConfig.put(Long.class, ToStringSerializer.instance);
People one = new People(10, "aaa", 10000000L);
System.out.println(JSON.toJSONString(one, stringSerializeConfig, new SerializerFeature[0]));
}
}
期待的正确结果
{"age":"10","hairNums":"10000000","name":"aaa"}
相关日志输出
{"age":10,"hairNums":"10000000","name":"aaa"}
The text was updated successfully, but these errors were encountered:
问题描述
使用 SerializeConfig.put(Integer.class, ToStringSerializer.instance)进行序列化,将integer类型转成string类型,未生效;
环境信息
重现步骤
期待的正确结果
{"age":"10","hairNums":"10000000","name":"aaa"}
相关日志输出
{"age":10,"hairNums":"10000000","name":"aaa"}
The text was updated successfully, but these errors were encountered: