【问题标题】:Retrofit + Gson convertor json RFC7159 supportRetrofit + Gson 转换 json RFC 7159 支持
【发布时间】:2018-02-10 10:07:43
【问题描述】:

在我的应用程序中,我使用 Gson 转换器进行改造。以下是gradles。

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.google.code.gson:gson:2.6.1'

从 Magento2 后端收到 json 格式的响应。这里的 JSON 标准是 RFC7159。 Gson 不支持它。就像作为回应,我只得到以下值

响应 1:“一些字符串”, 回应 2:是的

Gson 无法读取这些值。为了读取这些值或支持 RFC7159 标准,我需要做哪些更改。请提出建议。

【问题讨论】:

  • 您使用哪个版本的 GSON?
  • 如果您使用早于 2.6.1 的版本,我可以发布一个可行的解决方案

标签: android json gson retrofit


【解决方案1】:

GSON 2.6.1 及更新版本开始支持 RFC7159,只需将 gradle 中的依赖更新为:

compile 'com.google.code.gson:gson:2.8.1'

还有,请不要忘记删除旧/以前的版本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2019-03-24
    • 2015-12-02
    • 2021-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-10
    相关资源
    最近更新 更多