fastjson中object转string时的配置项,包括
1. 是否显示value为null的项
2. 是否格式化显示字符串
3. 日期是否格式化显示为可读字符串
...
这些的配置均在SerializerFeature枚举类中,示例如下:
JSONObject object = new JSONObject();
object.put("name", "wei");
object.put("age", null);
object.put("date", new Date());
String jsonString = JSON.toJSONString(object,
SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat);
System.out.println(jsonString);