开发者

String formatting c# decode?

开发者 https://www.devze.com 2022-12-19 00:00 出处:网络
I have a string which looks like this \'%7B%22id%22%3A开发者_如何学Python1%2C%22name%22%3A%22jim%22%7D\' When read from a cookie it is in fact a JSON object and should look like {\"id\":1,\"name\":\"j

I have a string which looks like this '%7B%22id%22%3A开发者_如何学Python1%2C%22name%22%3A%22jim%22%7D' When read from a cookie it is in fact a JSON object and should look like {"id":1,"name":"jim"}

Do I need to HTML decode the string to make it appear in the correct JSON notation?

Thanks,


Look at HttpUtility.UrlDecode in System.Web


Also assuming your using .Net 3.5 check this article by ScottGu and follow up from Scott Longnecker that allows you to convert c# classes to json and viceversa.

http://tiredblogger.wordpress.com/2007/10/03/to-and-fromjson-extension-methods/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号