Proper JSON formatting a C# String
Question
If you do this in MVC:
var jsonData =
new { myimage =
"<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />" };
return Json(jsonData);
You get this as a value
"\u003cimg alt=\"\" src=\"/Content/images/ShowFPots.png\" /\u003e"
How do I get this as a value, or will the <> interpret correctly when I add them to the innerHtml??
"<img alt=\"\" src=\"/Content/images/ShowFPots.png\" />"
Solution
that is correct javascript, unicode encoding. It'll be fine inserting it into html/DOM
https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Unicode
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow