Json类型的String 取出里面参数的值

1、前端参数

var paramJson = {
                id: id,
                name: name,
                list: list
            };
            doAjax(
                zuulUrl + "/xx/xx/xx",
                "POST",
                {paramJson: JSON.stringify(paramJson)},
                function (data) {
                  
                },
                function () {
                   
                }
            );

1.1、Json参数:paramJson

{
"id":"1",
"name":"aaa",
"list": [
            {
                "accountName":"aa",
                "createOperator":"12",
                "createTime":"2019-12-03 15:14:37",
            },
            {
                "accountName":"zz",
                "createOperator":"23",
                "createTime":"2019-12-03 17:00:24",
            }
        ]
}

2、后端参数
2.1、实体类
xx.java
2.2、Controller

@RequestMapping(value = "save", method = RequestMethod.POST)
    public boolean save(String paramJson){
        return xxService.save(JSONObject.parseObject(paramJson, xx.class));
    }

3、Service

boolean save(xx xx);

4、Impl
for 循环获得

            JSONObject reagobj = (JSONObject) xx.getList().get(i);

值:reagobj

{
                "accountName":"aa",
                "createOperator":"12",
                "createTime":"2019-12-03 15:14:37",
            }

获得值
比如获得 accountName

reagobj.getString("accountName");

你可能感兴趣的:(Java)