如何删除json字符串中的特殊字符 [英] how to remove special charcters in json string

查看:992
本文介绍了如何删除json字符串中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何删除json字符串中的特殊字符,如方框等特殊字符.... pls让我知道解决方案..任何一个...

how to remove special characters in json string ,special charcters like square boxes....pls let me know the solution .. any one ...

推荐答案

您所说的方形框很可能是由JSON字符串中编码的特殊字符引起的.

您没有提供很多线索,例如如何将数据获取到字符串中,字符串的外观或如何尝试在应用程序中使用字符串,从而很难给出任何具体答案.

通过函数传递字符串以进行清理是一个选项,具体取决于您尝试执行操作的方式.

如果使用的是JSON javascript库,则在stringify和parse方法中有一个可选的回调替换器和reviver,可在其中将字符串传递给特殊函数以执行任何自定义操作.

看; http://www.json.org/js.html [
The square boxes as you call them are most likely caused by special characters being encoded in the JSON string.

Your not giving many clues as how you are getting the data into the string, what the string looks like, or how you are trying to use the string in your app, making it difficult to give any specific answer.

Pass the string through a function to cleanse is an option depending on how you are trying to do things.

If you are using the JSON javascript library, there in the stringify and parse methods there is an optional callback replacer and reviver where you can pass the string through to special functions to do any custom operations.

See; http://www.json.org/js.html[^]


这篇关于如何删除json字符串中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆