kamikat / moshi-jsonapi

JSON API v1.0 Specification in Moshi.
MIT License
156 stars 34 forks source link

Attributes title not string #52

Closed antonicg closed 7 years ago

antonicg commented 7 years ago

Is there any trouble if the attributes object inside a Resource has a title that is an object instead of String? I have this case, also I'm trying to use my own attributes object with no success. Is a limitation of the library?

kamikat commented 7 years ago

I think we can handle following data with this library

{
    "type": "articles",
    "id": "tlgGJKIqxIo",
    "attributes": {
        "title": {
            "value": "This is the full title",
            "short": "Title in short"
        }
    }
}

And the Java code:

public class TitleObject {
    String value;
    String short;
}

The Article class like:

@JsonApi(type = "articles")
public class Article {
    TitleObject title;
    // ...
}

You can use customized adapter for TitleObject as is described by moshi.

antonicg commented 7 years ago

Okay thanks!