有什么方法可以将 JSONAPI 规范与 Retrofit 一起使用吗?不知道这将如何工作或如何开始,有什么帮助吗?
我找到了这个要点:https://gist.github.com/Gregadeaux/cbcc3781fda9d7fa6498 ,它使用 RxJava 和其他一些库。
另外,是否需要转换器?
谢谢。
最佳答案
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);
关于java - 需要改造 JSONAPI 转换器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32589331/