Modify JSONAPI converter?

Is there any way to use the JSONAPI specification with Retrofit ?, don’t know how this will work or how to get started, any help ?.

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

Also, do I need a converter ?.

Thanks.

+4
source share
2 answers

retrofit provides a list of existing JSON converters, you can also implement Converter.Factoryand provide your own converter. You can then pass your class to the instance when creating the adapter.

:

0

https://github.com/jasminb/jsonapi-converter - ,

// 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);
0

Source: https://habr.com/ru/post/1607497/


All Articles