!22 修复通过反射 组装出 contentModel,对非对象字符串使用JSON#parseObject()报错问题

Merge pull request !22 from MBC/master
pull/11/head
Java3y 2 years ago committed by Gitee
commit 38cd0efa77
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -2,6 +2,7 @@ package com.java3y.austin.service.api.impl.action;
import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
@ -114,7 +115,7 @@ public class AssembleAction implements BusinessProcess<SendTaskModel> {
if (StrUtil.isNotBlank(originValue)) { if (StrUtil.isNotBlank(originValue)) {
String resultValue = ContentHolderUtil.replacePlaceHolder(originValue, variables); String resultValue = ContentHolderUtil.replacePlaceHolder(originValue, variables);
Object resultObj = JSON.parseObject(resultValue, field.getType()); Object resultObj = JSONUtil.isJsonObj(resultValue) ? JSONUtil.toBean(resultValue, field.getType()) : resultValue;
ReflectUtil.setFieldValue(contentModel, field, resultObj); ReflectUtil.setFieldValue(contentModel, field, resultObj);
} }
} }

Loading…
Cancel
Save