【JSON】随笔记
1、Json对象列表
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
/** * 将传入的JSON参数转换为list * "[{\"activeId\":\"111\",\"circleId\":\"222\",\"redEnvelopeName\":\"\",\"securityCode\":\"\",\"activeStartTime\":\"\"}]"; * @param configureListJson 配置项json */ private List<RedPacketConfiguration> getConfigureList(String configureListJson) throws JSONException{ List<RedPacketConfiguration> list; try { list = JSONObject.parseArray(configureListJson, RedPacketConfiguration.class); } catch (Exception e) { logger.error("JSON 转换异常,JSON="+configureListJson); AteyeLogHelper.writeRedPacketLog("JSON 转换异常,JSON="+configureListJson); throw new JSONException("JSON 转换异常,JSON="+configureListJson); } return list; }
List list = JSONObject.parseArray("[\"143754\"]", String.class); System.out.println(list);