I have a Json
saved in database as string:
"{ \"path\" : \"a.crx\", \"uniteDeVolume\" : \"g or ml\", \"unites\" : \"Acts/Volume\", \"nbIndevMin\" : \"20\", \"nbJours\" : \"6 to 7\", \"ventilDepart\" : \"20051\" }"
When I want to read this field from database, and to deserialize to BsonDocument, the returned value is
"\"{ \\\"path\\\" : \\\"a.crx\\\", \\\"uniteDeVolume\\\" : \\\"g or ml\\\", \\\"unites\\\" : \\\"Acts/Volume\\\", \\\"nbIndevMin\\\" : \\\"20\\\", \\\"nbJours\\\" : \\\"6 to 7\\\", \\\"ventilDepart\\\" : \\\"20051\\\" }\""
How to eleminate the escape characters?
I would use Regex from 'System.Text.RegularExpressions'
var escapedString ="\"{ \\\"path\\\" : \\\"a.crx\\\", \\\"uniteDeVolume\\\" : \\\"g or ml\\\", \\\"unites\\\" : \\\"Acts/Volume\\\", \\\"nbIndevMin\\\" : \\\"20\\\", \\\"nbJours\\\" : \\\"6 to 7\\\", \\\"ventilDepart\\\" : \\\"20051\\\" }\"";
var unescapedString = Regex.Unescape(escapedString);
returns the following
"{ "path" : "a.crx", "uniteDeVolume" : "g or ml", "unites" : "Acts/Volume", "nbIndevMin" : "20", "nbJours" : "6 to 7", "ventilDepart" : "20051" }"
You can visit this link, It might help you
http://www.codeproject.com/Articles/371232/Escaping-in-Csharp-characters-strings-string-forma
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.