fastjson v1.2.44 @JSONCreator注解不生效

jucafojl  于 2021-11-27  发布在  Java
关注(0)|答案(0)|浏览(740)
public ActionHandlerDTO() {
}

@JSONCreator
public ActionHandlerDTO(@JSONField(name = "stopPlay") Boolean stopPlay,
                        @JSONField(name = "removeHint") Boolean removeHint,
                        @JSONField(name = "actionResponseType") String actionResponseType,
                        @JSONField(name = "detail") String detail) {
	this.stopPlay = stopPlay;
	this.removeHint = removeHint;
	this.actionResponseType = actionResponseType;
	ActionResponseTypeEnum type = ActionResponseTypeEnum.index(actionResponseType);
	if (type != null && type.getClazz() != null) {
		this.detailDTO = JSON.parseObject(detail, type.getClazz());
	}
}

构造方式
JSON.parseObject(text,new TypeReference<Map<String,ActionHandlerDTO>>() {})

会走入默认构造器,不会使用带有@JSONCreator的构造器。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题