Closed taynanbonaldo closed 5 years ago
I tried to use Java instead of Kotlin in my POJOs (and removing moshi-kotlin dependency).
I tried to intercept API response using OkHttp and convert "JsonObject" relationship to "JsonArray" (because array of stores relationship works!).
I tried to remove "stores" from relationship to see if with "cover_image" isolated would work.
I tried to rename entities, delete and re-create them, rename json keys.
But none of the attempts was successfully.
The more stranger here is that all "cover_image" and "store" objects are on Moshi Document "included" array. As well I can access the cover_image object using document.find< CoverImage >(ResourceIdentifier).
Why it not fill in my HasOne< CoverImage > attribute?
Any suggestion?
Missing @Json(name = "cover_image")
on Voucher.coverImage
?
You are totally right! I feel ashamed for not having tried this simple alternative! I had not thought of that, because I thought that by using the "HasOne" type it was not necessary to add the annotation ... it was extremely wrong! Would it be the case to add this information in Read Me? Or is this too obvious to be added? Hehehe
Anyway, thank you very much for the attention!
Hi,
I'm using moshi-jsonapi and moshi-jsonapi-retrofit-converter 3.5.0 with moshi and moshi-kotlin 1.8.0 to parse response of my API.
I have 3 classes:
Voucher
CoverImage
Store
And my API:
The response is parsed succeed, as well has "included" array parsed with CoverImage and Stores.
But when I get a Voucher Document from ArrayDocument response and try to retrieve its CoverImage, its null. However, when I read Stores, the array was populated with itens related to Voucher as expected.
Here is my Json response:
I'm doing anything wrong? Why HasOne relation wasn't resolved?