JsonObject.GetNamedString返回而不是空格

时间:2012-10-25 13:43:05

标签: windows-8

JsonObject的GetNamedString方法正在为空间返回& nbsp。例如,“The String”以& nbspThe String& nbsp的形式返回。有没有解决方法来解决这个问题?

1 个答案:

答案 0 :(得分:0)

如何通过HtmlDecodeConvertToText运行它 - 取决于您对字符串的期望内容:

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"));

顺便说一下,我确实必须在字符串中明确地放置nbsp;才能使它出现,所以怀疑你得到的JSON是嵌入的(而不是默认情况下这样做)。

相关问题