class A declares multiple JSON fields

前端 未结 8 776
温柔的废话
温柔的废话 2020-12-01 02:21

i have a class A which has some private fields and the same class extends another class B which also has some private fields which are in class A.

public cla         


        
8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 02:55

    In my case I was dumb enough to register an adapter with X class, and try to serialize fromJson with Y class:

    final GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(Game.class, new TournamentSerializer());
    final Gson gson = gsonBuilder.create();
    
    createdTournament = gson.fromJson(jsonResponse.toString(), Tournament.class);
    

提交回复
热议问题