Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String formatting c# decode?

I have a string which looks like this '%7B%22id%22%3A1%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,

like image 474
van Avatar asked Dec 22 '22 06:12

van


2 Answers

Look at HttpUtility.UrlDecode in System.Web

like image 162
Mike Marshall Avatar answered Jan 01 '23 02:01

Mike Marshall


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/

like image 28
Phil Strong Avatar answered Jan 01 '23 00:01

Phil Strong