需要使用Retrofit JSONAPI转换器吗?

6
有没有办法在Retrofit中使用JSONAPI规范?不知道这将如何运作或如何开始,请帮忙吗?
我在这里找到了一个代码片段:https://gist.github.com/Gregadeaux/cbcc3781fda9d7fa6498,它使用了RxJava和其他一些库。
此外,需要转换器吗?
谢谢。
2个回答

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

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接