java - 需要改造 JSONAPI 转换器吗?

标签 java android converter retrofit json-api

有什么方法可以将 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/

相关文章:

pdf - Ghostscript:使用嵌入字体而不是轮廓曲线将 PDF 转换为 EPS

java - 覆盖访问私有(private)成员的公共(public)方法

java - 一旦部署在 Android 设备上,你能否即时运行 "compact"SQLite 数据库?

hex - 使用 flutter 中的 HexEncoder 类

java - 是否可以自动将java代码转换为PHP?

Android 向后兼容,但仍使用最新的 API 功能

java.lang.NoSuchFieldError : STANDARD_IMPORTS

java - 使用 hibernate 从主键复合的表中读取数据

java - 如何从电话管理器中检查电话号码格式是否有效?

Android 在固定位置找到方位