WebUtility.HtmlDecode无法解码字符串

Cor*_*son 2 c# json

我正在WebUtility.HtmlDecode尝试解码一个字符串,其中一部分如下:

checkin=%7B%22id%22%3A%224f612730e4b071dd72e3749d%22%2C%22createdAt%22%3A1331767088%2C%22type%22%3A%22checkin%22%2C%22timeZone%22%3A%22America%5C%2FDenver%22%2C
Run Code Online (Sandbox Code Playgroud)

但是,WebUtility.HtmlDecode无法解码它,任何一个.如果重要,这是我如何生成字符串:

public static Dictionary<String, dynamic> DeserializeRequestStream(Stream requestStream, int contentLength)
        {
            requestStream.Position = 0; //Since a custom route with post data AND an ID passed in a parameter reads this stream. Damn bugs.
            var bytes = new byte[contentLength];
            requestStream.Read(bytes, 0, contentLength);    //(int)requestStream.Length - contentLength
            var jsonResponse = System.Text.Encoding.UTF8.GetString(bytes, 0, bytes.Length);
            var decodedResponse =  WebUtility.HtmlEncode(jsonResponse);
           //...snip...
        }
Run Code Online (Sandbox Code Playgroud)

这应该是编码的JSON数据,我正在从POST请求中读取.如何将此字符串解码为常规JSON?

编辑: Lasse V. Karlsen指出这实际上是URL编码的,而且我一直在咆哮错误的树.问题仍然存在:我将如何解码?

Joh*_*ick 6

最简单的方法是HtmlDecode改为UrlDecode.

原因:输入字符串checkin=%7B%22id%22%3A...是URL编码的,而不是HTML编码的.