简体   繁体   中英

JsonObject.GetNamedString is returning &nbsp instead of space

GetNamedString method of JsonObject is returning &nbsp for space. For ex." The String " is returned as &nbspThe String&nbsp. Is there any workaround to fix this issues?

how about running it through HtmlDecode or ConvertToText - depending on what content you expect in the string:

JsonObject s = new JsonObject();
s.Add(new KeyValuePair<string, IJsonValue>("val",  JsonValue.CreateStringValue("&nbsp;The String&nbsp;")));
var t = System.Net.WebUtility.HtmlDecode(s.GetNamedString("val"));

By the way, I did have to explicitly put the nbsp; in the string to get it to appear, so suspect the JSON you are getting has that embedded (versus it just doing so by default).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM