We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get data from one object, but that object have 2 different types?
I have object named 'metric', but 'metric' have 2 different types
The text was updated successfully, but these errors were encountered:
it appears you need to use abstract class and polymorphic adapter factory, like this:
@JsonApi(type = TYPE) data class SomeType( .... val metric: HasOne<Metric> = HasOne() ...) : Resource()
then
abstract class Metric : Resource()
and
@JsonApi(type = "gamePointMetric") data class GamePointMetric(...) : Metric()
and finally
val adapterFactory = ResourceAdapterFactory .builder() .add(GamePointMetric::class.java) .add(GameStateMetric::class.java) .build() ... Moshi.Builder() .add(adapterFactory) .add(PolymorphicJsonAdapterFactory.of(Metric::class.java, "type")  .withSubtype(GamePointMetric::class.java, "GamePointMetric")  .withSubtype(GameStateMetric::class.java, "GameStateMetric") ) .build()
solution thanks to @MDikkii
Sorry, something went wrong.
No branches or pull requests
How to get data from one object, but that object have 2 different types?
I have object named 'metric', but 'metric' have 2 different types
The text was updated successfully, but these errors were encountered: