ARouter Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to XXBean

5rgfhyps  于 2022-10-22  发布在  Java
关注(0)|答案(1)|浏览(287)

生成的类

public class XXDownloadActivity$$ARouter$$Autowired implements ISyringe {
  private SerializationService serializationService;

  @Override
  public void inject(Object target) {
    serializationService = ARouter.getInstance().navigation(SerializationService.class);
    StickerDownloadActivity substitute = (StickerDownloadActivity)target;
    substitute.mainStickerBean = (com.xx.bean.XXBean.InnerXXBean) substitute.getIntent().getSerializableExtra("key_data");
  }
}

jsonService

@Route(path = "/service/json")
public class JsonServiceImpl implements SerializationService {
    Gson gson = new Gson();
    @Override
    public <T> T json2Object(String input, Class<T> clazz) {
//        return JSON.parseObject(input, clazz);
        return gson.fromJson(input,clazz);
    }

    @Override
    public String object2Json(Object instance) {
//        return JSON.toJSONString(instance);
        return gson.toJson(instance);
    }

    @Override
    public <T> T parseObject(String input, Type clazz) {
//        return JSON.parseObject(input, clazz);
        return gson.fromJson(input,clazz);
    }

    @Override
    public void init(Context context) {

    }
}
knsnq2tg

knsnq2tg1#

你看你的 XXBean 是不是实现了 Serializable

相关问题