Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastjson1.x 兼容版本 2.0.14 调用 JSON.parseArray(jsonData, clazz);出错 无法转换 #778

Closed
afish177 opened this issue Sep 17, 2022 · 15 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@afish177
Copy link

afish177 commented Sep 17, 2022

问题描述

简要描述您碰到的问题。
#584 此项修复 fastjson1.x 更新最新兼容版本2.0.14
测试config属性 JSON.parseArray 依旧还是 null (1.2.x 版本 无误 2.x以上版本 获取确是null)
如图:
image
image

image

image
image

环境信息

请填写以下信息:

  • OS信息: [e.g.:CentOS 8.4.2105 4Core 3.10GHz 16 GB]
  • JDK信息: [e.g.:Openjdk 1.8.0_312]
  • 版本信息:[e.g.:Fastjson2 2.0.14 1.x兼容版本 ]

重现步骤

如何操作可以重现该问题:
#584 详细

  1. 使用 xxx.xxx 方法
  2. 输入 ... 数据
  3. 出现 ... 错误
//可在此输入示例代码
``` 详细见 #584



测试数据
jsonData :

[{
	"__config__": {
		"formId": 115,
		"visibility": ["pc", "app"],
		"pfKey": "select",
		"defaultValue": "",
		"dataType": "static",
		"dictionaryType": "",
		"dragDisabled": false,
		"label": "所属项目",
		"propsUrl": "",
		"showLabel": true,
		"required": false,
		"props": {
			"label": "fullName",
			"value": "id"
		},
		"renderKey": 1611127618069,
		"tableName": "test_subpackage",
		"layout": "colFormItem",
		"tagIcon": "icon-ym icon-ym-generator-select",
		"tag": "el-select",
		"span": 24
	},
	"__vModel__": "projectS",
	"disabled": false,
	"placeholder": "请选择",
	"__slot__": {
		"options": [{
			"fullName": "选项一",
			"id": "1"
		}, {
			"fullName": "选项二",
			"id": "2"
		}]
	}
}, {
	"__config__": {
		"formId": 101,
		"visibility": ["pc", "app"],
		"pfKey": "depSelect",
		"dragDisabled": false,
		"label": "所属部门",
		"showLabel": true,
		"required": false,
		"renderKey": 1606979361829,
		"tableName": "test_subpackage",
		"layout": "colFormItem",
		"tagIcon": "icon-ym icon-ym-generator-department",
		"changeTag": true,
		"tag": "dep-select",
		"regList": [],
		"span": 12
	},
	"__vModel__": "depNameA",
	"disabled": false,
	"placeholder": "请选择"
}, {
	"clearable": true,
	"__config__": {
		"formId": 116,
		"visibility": ["pc", "app"],
		"pfKey": "userSelect",
		"dragDisabled": false,
		"label": "填单人",
		"trigger": "click",
		"showLabel": true,
		"required": false,
		"tableName": "test_subpackage",
		"renderKey": 1652256065583,
		"layout": "colFormItem",
		"tagIcon": "icon-ym icon-ym-generator-user",
		"tag": "user-select",
		"regList": [],
		"span": 12
	},
	"multiple": false,
	"__vModel__": "applys",
	"disabled": false,
	"placeholder": "请选择",
	"on": {
		"change": "({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, request, getFieldOptions, setFieldOptions }) => {\n    // 在此编写代码\n    \n}"
	}
}, {
	"clearable": true,
	"prefix-icon": "",
	"show-password": false,
	"__config__": {
		"formId": 118,
		"visibility": ["pc", "app"],
		"pfKey": "comInput",
		"noShow": false,
		"dragDisabled": false,
		"label": "承包方",
		"trigger": "blur",
		"showLabel": true,
		"required": false,
		"tableName": "test_subpackage",
		"renderKey": 1652256104063,
		"layout": "colFormItem",
		"tagIcon": "icon-ym icon-ym-generator-input",
		"tag": "el-input",
		"regList": [],
		"span": 24
	},
	"readonly": false,
	"__vModel__": "contractor",
	"style": {
		"width": "100%"
	},
	"disabled": false,
	"placeholder": "请输入",
	"show-word-limit": false,
	"__slot__": {
		"prepend": "",
		"append": ""
	},
	"suffix-icon": "",
	"on": {
		"change": "({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, request, getFieldOptions, setFieldOptions }) => {\n    // 在此编写代码\n    \n}",
		"blur": "({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, request, getFieldOptions, setFieldOptions }) => {\n    // 在此编写代码\n    \n}"
	}

}]




对应实体class 

@Data
public class FieLdsModel {
    private ConfigModel config;
    private SlotModel slot;
    private String placeholder;
    private Object style;
    private Boolean clearable;
    private String prefixicon;
    private Integer precision;
    private String suffixicon;
    private String maxlength;
    private Boolean showWordLimit;
    private Boolean readonly;
    private Boolean disabled;
  
    private String vModel="";
    
    private String modelId="";
   
    private String relationField;
    private Boolean hasPage;
    private String pageSize;
    private String type;
    private Object autosize;
    private Integer step;
    private Boolean stepstrictly;
    private String controlsposition;
    private Object textStyle;
    private Integer lineHeight;
    private Integer fontSize;
    private Boolean showChinese;
    private Boolean showPassword;

   
    private String size;
    private Boolean filterable;
    
    private String showField;
}

@Data
public class ConfigModel {

    private String label;
    private String labelWidth;
    private Boolean showLabel;
    private Boolean changeTag;
    private Boolean border;
    private String tag;
    private String tagIcon;
    private boolean required = false;
    private String layout;
    private String dataType;
    private Integer span = 24;
    private String pfKey;
    private String dictionaryType;
    private Integer formId;
    private Long renderKey;
    private Integer columnWidth;
    private List<RegListModel> regList;
    private Object defaultValue;
    private String active;
    
    private String options;
   
    private String valueType;
    private String propsUrl;
    private String optionType;
    private ConfigPropsModel props;
   
    private Boolean showTitle;
    private String tableName;
    private List<FieLdsModel> children;

   
    private String visibility="[\"app\",\"pc\"]" ;

    
    private String rule;

    
    private String trigger="blur";
   
    private Boolean noShow=false;
   
    private int childNum;
    private String model;

   
    private boolean app = true;
    private boolean pc = true;
}

@Data
public class SlotModel {
	private List<Map<String,Object>> options;
}

@Data
public class RegListModel {
    private String pattern;
    private String message;
}

@Data
public class ConfigPropsModel {
    private String label;
    private String value;
}

### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*
JSON.parseArray(jsonData, clazz);
希望能转换出 对应属性 的值


![image](https://user-images.githubusercontent.com/32056262/190836523-d7d30a6d-2bce-41b3-b2f7-79af26aa60ae.png)

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*


#### 附加信息
*如果你还有其他需要提供的信息可以在这里填写可以提供截图视频等)。*
@afish177 afish177 added the bug Something isn't working label Sep 17, 2022
@wenshao wenshao added this to the 2.0.15 milestone Sep 17, 2022
@wenshao
Copy link
Member

wenshao commented Sep 17, 2022

SlotModel 这个类的代码发一下

@wenshao
Copy link
Member

wenshao commented Sep 17, 2022

能帮忙简化一个重方便重现问题的testcase么?

@afish177
Copy link
Author

SlotModel 这个类的代码发一下

可以 删除 那些 不存在得实体类 就留ConfigModel 基本属性 对象属性可以 删除测试

@afish177
Copy link
Author

afish177 commented Sep 17, 2022

能帮忙简化一个重方便重现问题的testcase么?

JSON.parseArray(jsonData, clazz); 定义好 对应实体类(FieLdsModel ConfigModel ....) 放入上面 jsonData 数据 调用JSON.parseArray(jsonData, clazz) 即可

@afish177
Copy link
Author

SlotModel 这个类的代码发一下

对应缺失 类 已补充 麻烦温大佬 看看

@wenshao
Copy link
Member

wenshao commented Sep 17, 2022

JSON.parseArray(jsonData, clazz) ,
这里传入的clazz是什么?很抱歉,一直没搞清楚你问题

@afish177
Copy link
Author

afish177 commented Sep 17, 2022

JSON.parseArray(jsonData, clazz) , 这里传入的clazz是什么?很抱歉,一直没搞清楚你问题

class 是 FieLdsModel 这个类

JSON.parseArray(jsonData, FieLdsModel.class)
FieLdsModel ff = JSON.parseArray(jsonData, FieLdsModel.class)
对应得 config属性 里面 是null

image
image

不知我 描述清楚没 这个在1.2.x 是会有值得 但是2.x得 版本 好像不行

@wenshao
Copy link
Member

wenshao commented Sep 17, 2022

目前是不支持识别连续__的名称了,你这个比较奇怪

@afish177
Copy link
Author

afish177 commented Sep 17, 2022

目前是不支持识别连续__的名称了,你这个比较奇怪

我需要这个得 因为我得项目 就有这个(1.2.x 是会有值得 但是2.x得 版本 好像不行)

@wenshao
Copy link
Member

wenshao commented Sep 17, 2022

可以通过JSONField额外配置

    @Data
    public static class FieLdsModel {
        @JSONField(alternateNames = "__config__")
        private ConfigModel config;

支持__会有别别的兼容问题,所以就不支持连续下划线了

@afish177
Copy link
Author

可以通过JSONField额外配置

    @Data
    public static class FieLdsModel {
        @JSONField(alternateNames = "__config__")
        private ConfigModel config;

支持__会有别别的兼容问题,所以就不支持连续下划线了

好 我试试 谢谢 温大佬 因为1.2.83 我一直没升级 是因为这个版本 是支持__ 2.x 我就没升级上去

@wwkk7080
Copy link

可以通过JSONField额外配置

    @Data
    public static class FieLdsModel {
        @JSONField(alternateNames = "__config__")
        private ConfigModel config;

支持__会有别别的兼容问题,所以就不支持连续下划线了

好 我试试 谢谢 温大佬 因为1.2.83 我一直没升级 是因为这个版本 是支持__ 2.x 我就没升级上去

这种方式出现其他报错了

@wenshao
Copy link
Member

wenshao commented Oct 5, 2022

@wwkk7080 出现什么其他报错了?

@wenshao
Copy link
Member

wenshao commented Oct 5, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.15
问题修复,请用新版本

@wenshao wenshao modified the milestones: 2.0.15, 2.0.16 Oct 5, 2022
@wenshao wenshao closed this as completed Oct 22, 2022
@wenshao wenshao modified the milestones: 2.0.16, 2.0.15 Oct 22, 2022
@wenshao wenshao added the fixed label Oct 22, 2022
@wenshao
Copy link
Member

wenshao commented Oct 22, 2022

https://github.com/alibaba/fastjson2/releases/tag/2.0.16
问题已修复,请用2.0.16版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants