Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Swift里的JsonUtil无法解析特殊字符 #154

Open
ChunPangWong opened this issue Oct 22, 2021 · 6 comments
Open

Swift里的JsonUtil无法解析特殊字符 #154

ChunPangWong opened this issue Oct 22, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@ChunPangWong
Copy link

ChunPangWong commented Oct 22, 2021

"҉昵称
Swift里的JsonUtil无法解析上述特殊字符。
result = result.replacingOccurrences(of: "\"", with: "\\\"");
无法成功替换双引号

@JiangJuHong
Copy link
Owner

请提供更详细的案例,这有助于排查问题

@ChunPangWong
Copy link
Author

ChunPangWong commented Oct 22, 2021

{ "nickName":"\"҉昵称" }
用户昵称带特殊字符时,获取用户信息等,JsonUtil.toJson拼接出来的字符串无法通过flutter端的jsondecode

@JiangJuHong
Copy link
Owner

好的,我会检查这个问题,如果存在会尝试解决它

@ChunPangWong
Copy link
Author

thanks

@JiangJuHong JiangJuHong added the bug Something isn't working label Oct 22, 2021
@ChunPangWong
Copy link
Author

result = result.unicodeScalars.map { scalars in if(scalars == "\""){ return "\\\(scalars)" } return "\(scalars)" }.joined()
目前暂时通过unicode替换,重组字符串

@JiangJuHong
Copy link
Owner

好的,感谢你的帮助,我会尝试这种方法的可行性

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants