У меня есть класс, который я пытаюсь проанализировать с помощью модернизации:
@JsonClass(generateAdapter = true)
class StickerDto(
@Json (name = "totalAnimatedStickers") val total: Int,
@Json(name = "pages") val pages: Int,
@Json(name = "data") val stickers: List<Sticker>
)
@JsonClass(generateAdapter = true)
class Sticker(
@Json(name = "name") val name: String,
@Json(name = "id") val id: String,
@Json(name = "stickerData") val stickerData: Map<String, Any>,
var isSelected:Boolean = false
)
Ниже приведено начало ответа, который я получаю с 200. Обратите внимание, что атрибут "stickerData" класса стикера равен очень длинная JSON строка, которую я пытаюсь получить как карту. Я не могу включить его целиком, потому что он очень длинный. Попытка получить его как строку не удалась, потому что Retrofit ожидает объект JSON.
{"totalAnimatedStickers":48,"pages":6,"data":[{"name":"zany_face","id":"9b50585a-1fa5-4b02-9a50-d1310ccc7d0a","stickerData":{"v":"5.5.7","fr":24,"ip":0,"op":48,"w":1024,"h":1024,"nm":"zany_face","ddd":0,"assets":[{"id":"comp_0","layers":[{"ddd":0,"ind":1,"ty":3,"nm":"C | Face_CTRL","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[512,849.778,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":0,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1]},"o":{"x":[0.292,0.292,0.193],"y":[0.025,0.034,0]},"t":4,"s":[105,94,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0]},"t":8,"s":[97.304,102.544,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":12,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":18,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,1]},"o":{"x":[0.292,0.292,0.193],"y":[0,0,0]},"t":21,"s":[105,94,100]},{"i":{"x":[0,0,0.704],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0]},"t":24,"s":[96.304,104.544,100]},{"t":32,"s":[100,100,100]}],"ix":6}},"ao":0,"ef":[{"ty":5,"nm":"Controller","np":13,"mn":"Pseudo/DUIK controller","ix":1,"en":1,"ef":[{"ty":6,"nm":"Icon","mn":"Pseudo/DUIK controller-0001","ix":1,"v":0},{"...........
Вот метод, который я использую для создания экземпляра модификации:
private fun createNewFriendsClient (authRefreshClient : AuthRefreshClient, preferencesInteractor: PreferencesInteractor): FriendsApiClient {
val logger = run {
val httpLoggingInterceptor = HttpLoggingInterceptor()
httpLoggingInterceptor.apply {
httpLoggingInterceptor.level = if (BuildConfig.DEBUG) HttpLoggingInterceptor.Level.BODY else HttpLoggingInterceptor.Level.NONE
}
}
val okHttp = OkHttpClient.Builder().addInterceptor(logger).authenticator(RefreshUserAuthenticator(authRefreshClient, preferencesInteractor,
UnauthorizedNavigator(SDKInternal.appContext, Interactors.preferences))).build()
return Retrofit.Builder()
.client(okHttp)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.baseUrl(Interactors.apiEndpoint)
.build()
.create(FriendsApiClient::class.java)
}
Моя проблема в том, что атрибут стикеров класса StickerDto имеет значение null после вызова, что означает, что что-то не так с тем, как я анализирую эти данные с помощью Retrofit. Что мне не хватает?