【JSON】随笔记

一、Json对象列表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);
相关文章
相关标签/搜索