首页 > 解决方案 > 如何使用对象映射器从 JSON 字符串中删除反斜杠

问题描述

下面是使用对象映射器从对象中获取 Json 字符串的代码:

let jsonString = Mapper().toJSONString(freechargeRequest)

但输出带有反斜杠,如下所示:

"{\"region\":\"http:\/\/testrm.getquickride.com:8080\/dishaapiserver\/qr_freecharge_failure.do\",\"merchantId\":\"8mILp0KGOdEG57\",\"productInfo\ ":\"auth\",\"mobile\":\"1357924680\",\"channel\":\"IOS\",\"amount\":\"200\",\"surl\": \"http:\/\/testrm.getquickride.com:8080\/dishaapiserver\/qr_freecharge_success.do\",\"merchantTxnId\":\"510420180705115938\"}"

我想要 JSON 字符串中没有反斜杠的输出。

标签: jsonswiftobjectmapper

解决方案


推荐阅读