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;
    }

}
原文地址:https://www.cnblogs.com/cgy-home/p/14951207.html