com.alibaba.fastjson.JSONArray cannot be cast to XX

PushData<Menu[]> pushData = FastJSONUtil.parsePojo(message, PushData.class);
List<Menu> menuList= JSONArray.parseArray(JSON.toJSONString(pushData.getData()), Menu.class);
menuList.forEach(e -> {
    log.info("e:{}", e);
});

关键地方是 

JSON.toJSONString(pushData.getData())把获取到的数组 实体类数据 转为String,然后转为对应的实体

其中 PushData

@Data
@NoArgsConstructor
public class PushData<T> {
    private String seqId = Long.toHexString(System.currentTimeMillis());

    private String code = "00";

    private String type = "menu";

    private T data;

    public PushData(T data) {
        super();
        this.data = data;
    }

    public PushData(String type, T data) {
        this.data = data;
        this.type = type;
    }

}

 

com.alibaba.fastjson.JSONArray cannot be cast to XX

上一篇:vue+webpack+scss 开发项目


下一篇:Kubernetes:日志聚合分析系统—Loki的搭建与使用