2017-03-07 14:02
/**
* 扩展json处理,Long型和BigInteger转为字符串
*/
public class ExtJson extends JFinalJson {
@Override
public String toJson(Object object) {
if (object == null)
return "null";
if (object instanceof Long || object instanceof BigInteger) {
return "\"" + escape((String) object) + "\"";
}
return super.toJson(object);
}
@Override
protected String toKeyValue(String key, Object value, StringBuilder sb, int depth) {
if (value instanceof Long || value instanceof BigInteger) {
return super.toKeyValue(key, ConvertUtil.objectToString(value), sb, depth);
}
return super.toKeyValue(key, value, sb, depth);
}
}