【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);
相關文章
相關標籤/搜索