需要改装JSONAPI转换器吗?

neb*_*ros 5 java android converter retrofit json-api

有没有办法将JSONAPI规范用于Retrofit?,不知道这将如何工作或如何启动,任何帮助?

我找到了这个要点:https://gist.github.com/Gregadeaux/cbcc3781fda9d7fa6498,它使用RxJava和其他一些库.

还需要转换器吗?

谢谢.

小智 2

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);
Run Code Online (Sandbox Code Playgroud)