【问题标题】:How to use @SerializedName in Kotlin Multiplatform project?如何在 Kotlin 多平台项目中使用 @SerializedName?
【发布时间】:2019-11-07 11:28:18
【问题描述】:

我正在使用 Kotlin 多平台。我在 Json 响应中获取对象名称。 我想用其他名称映射对象名称。所以我发现使用@SerializedName。 但它不起作用。

它显示未解析的引用:SerializedName。

【问题讨论】:

    标签: kotlin kotlin-multiplatform kotlinx.serialization


    【解决方案1】:

    您可以使用官方的 kotlin 原生序列化库进行多平台。 here 描述了如何根据您使用的 gradle 语法(“应用插件”或“插件{..}”)将插件添加和应用到您的项目中。添加依赖项后,您可以使用 @SerialName 注释而不是 @SerializedName 来覆盖对象名称。

    【讨论】:

      猜你喜欢
      • 2020-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-02
      • 1970-01-01
      • 1970-01-01
      • 2020-07-29
      • 2018-06-20
      相关资源
      最近更新 更多