从JSON替换转义字符 [英] Replacing escape characters from JSON
本文介绍了从JSON替换转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将JSON字符串中的"\"字符替换为空白. 我该怎么办?
I want to replace the "\" character from a JSON string by a empty space. How can I do that?
推荐答案
我发现,从JSON字符串中删除所有转义字符的最简单,最佳方法是将字符串传递给 Regex.Unescape() 方法. 此方法返回一个新的字符串,即使没有\ n \ t等,也不会被转义.
I have found that the easiest and best way to remove all escape characters from your JSON string, is to pass the string into Regex.Unescape() method. This method returns a new string with no ecapes, even \n \t etc, are removed.
有关更多详细信息,请参见此MSDN文章: Regex.Unescape方法(字符串)(系统.Text.RegularExpressions)
这篇关于从JSON替换转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文