如何使用对象映射器从JSON字符串中删除反斜杠

时间:2018-07-05 06:33:04

标签: json swift objectmapper

这是使用对象映射器从对象获取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字符串中没有反斜杠的输出。

1 个答案:

答案 0 :(得分:-1)

尝试

jsonString!.replacingOccurrences(of: "\", with: "")