Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrofit JSONAPI converter needed?

Is there some way to use the JSONAPI spec with Retrofit?, don't know how this will work or how to start, any help?.

I found this gist: https://gist.github.com/Gregadeaux/cbcc3781fda9d7fa6498, it uses RxJava and some other libraries.

Also, is a converter needed?.

Thank you.

like image 342
nebiros Avatar asked Sep 15 '15 14:09

nebiros


1 Answers

https://github.com/jasminb/jsonapi-converter is what you're looking for

from the docs

// Create object mapper
ObjectMapper objectMapper = new ObjectMapper();

// Set serialisation/deserialisation options if needed (property naming strategy, etc...)

Retrofit retrofit = new Retrofit.Builder()
        .baseUrl("https://yourapi")
        .addConverterFactory(new JSONAPIConverterFactory(objectMapper, Book.class, Author.class))
        .build();

// Create service using service interface
MyBooksService booksService = retrofit.create(MyBooksService.class);
like image 126
Mark Salpeter Avatar answered Nov 11 '22 23:11

Mark Salpeter