欢迎光临
我们一直在努力

使用fastjson实现Map和Java Bean互转

MapJava Bean

public ResponseResult addDataTable(Map<String, Object> params) {
        String jsonString = JSON.toJSONString(params);
        DmDataTable dataTable = JSON.parseObject(jsonString, DmDataTable.class);
        DmApprovalInfo approvalInfo = JSON.parseObject(jsonString, DmApprovalInfo.class);
        return new ResponseResult(insertSelective(dataTable.setTableId(UUIDUtil.uuid())));
    }

Java BeanMap

OrganStaffDto staffDto = queryStaffDtoByOrganId(user2.get("organId"));
String jsonStr = JSON.toJSONString(staffDto);
Map<String,String> staffMap = (Map)JSON.parseObject(jsonStr);

References

  1. fastjson:javabean按字段(field)序列化存储为Map并反序列化
赞(0)
未经允许不得转载:Ddmit » 使用fastjson实现Map和Java Bean互转

评论 抢沙发

登录

找回密码

注册