【问题标题】:Klaxon's JSON pretty printing outputs "["result"]"Klaxon 的 JSON 漂亮打印输出 "["result"]"
【发布时间】:2017-07-14 08:00:18
【问题描述】:
val time = json.lookup<String?>("query.results.channel.title").toJsonString(true)

输出

["Yahoo! Weather - Nome,AK,US"]

有没有办法在没有括号和引号的情况下获得输出?

我猜是的

.replace("[\"","").replace("\"]","")

不是最好的方法

【问题讨论】:

    标签: json kotlin klaxon


    【解决方案1】:

    括号包含在默认实现中(请参阅最底部函数appendJsonStringImpl中的https://github.com/cbeust/klaxon/blob/master/src/main/kotlin/com/beust/klaxon/DSL.kt

    因此无法通过配置删除它们。

    如果你为这个特定的类编写一个扩展函数,它可能会起作用,但我想这不是你想要的。

    因此,如果不编写您自己的扩展(-function),目前这是不可能的。

    【讨论】:

      猜你喜欢
      • 2014-05-19
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      • 2021-01-31
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多