src/com/xx/supermarket/utils/JsonUtil2.java
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.xx.supermarket.utils;
import java.io.IOException;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import net.sf.ezmorph.MorphException;
import net.sf.ezmorph.MorpherRegistry;
import net.sf.ezmorph.object.AbstractObjectMorpher;
import net.sf.ezmorph.object.DateMorpher;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.util.JSONUtils;
public class JsonUtil2 {
private static final String[] DATE_FORMAT = { "yyyy-MM-dd HH:mm:ss" };
public static String toJson(Object o) {
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(java.util.Date.class, new DateJsonValueProcessor());
jsonConfig.registerJsonValueProcessor(java.sql.Timestamp.class, new DateJsonValueProcessor());
System.out.println(JSONObject.fromObject(o));
System.out.println(JSONObject.fromObject(o, jsonConfig).toString());
try {
return JSONObject.fromObject(o, jsonConfig).toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* 获取jsonObject对象
* @return
*/
public static JSONObject getJsonObject(){
return new JSONObject();
}
/**
* 获取JSONArray对象
* @return
*/
public static JSONArray getJSONArray(){
return new JSONArray();
}
/***
*
* @Title: toJsonArray
* @Description:把一个List转换为json字符串
* @param @param o
* @param @return 设定文件
* @return String 返回类型
* @Author
* @throws
*/
public static String toJsonArray(Object o) {
后面还有 137 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。