The response I’m returning from my api call via Retrofit has a dynamic value for each object. I need to be able to edit value in the @SerializedName annotation with each call.
Here’s the JSON response:
{ "data": { "/storage/emulated/0/DCIM/Camera/IMG_20190920_110850.jpg": { "id": "4f7e74d1-afa8-4924-a8ab-ea9360400b", "location": "279dbcd7666b/4f7e74d1-afa8-4924-a8ab-ea9360400b.jpg", "bucket": "challenge-submit" } } }
Here’s my data class:
data class UploadLinksResponse(
@SerializedName("data")
val data: UploadData
)
data class UploadData(
@SerializedName("/storage/emulated/0/DCIM/Camera/IMG_20190920_110850.jpg")
val media: MediaLink
)
data class MediaLink(
@SerializedName("id")
val id: String,
@SerializedName("bucket")
val bucket: String,
@SerializedName("location")
val uploadLocation: String
)
How can I set the SerializedName, which will be a unique value each time I upload?