【问题标题】:Json String Remove Backslash in SwiftJson字符串在Swift中删除反斜杠
【发布时间】:2020-12-28 11:31:17
【问题描述】:
[{\"item_gender\":\"Female\",\"item_type\":\"\",\"item_quantity\":\"1\",\"item_id\":\"21507\"}]

如何在 swift 4 中从 JSON 字符串中删除反斜杠 \

【问题讨论】:

  • 这里\在我提交时被删除如果有人对此有任何解决方案,请帮助我。
  • 这能回答你的问题吗? remove \n and slash \ from converted json string
  • 反斜杠是虚拟的,可以在字符串文字中显示双引号,它们在现实中不存在。

标签: arrays json swift


【解决方案1】:

请尝试以下代码以实现您的目标: JSON.parse(JSON.stringify("[{"item_gender":"Female","item_type":"","item_quantity":"1","item_id":"21507"}]")).toString()

【讨论】:

  • 我不知道 Swift 中的 JSON.parse、JSON.stringify 或 toString 方法。你能告诉我们这些方法是在哪里定义的吗?
  • 发现此链接可能对您有用 (avanderlee.com/swift/json-parsing-decoding)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-28
相关资源
最近更新 更多