I have a JSON string like below:
"\"{\\\"PersonNumber\\\":\\\"4537\\\",\\\"PersonName\\\":\\\"Jenny\\\"}\""
I want to convert this JSON to NameValueCollection and I have tried below codes. but I am getting an error :
string jsonString= "\"{\\\"PersonNumber\\\":\\\"4537\\\",\\\"PersonName\\\":\\\"Jenny\\\"}\""
System.Web.Script.Serialization.JavaScriptSerializer jss1;
NameValueCollection nvc1;
jss1 = new System.Web.Script.Serialization.JavaScriptSerializer();
nvc1 = new NameValueCollection();
try { nvc1 = jss1.Deserialize<NameValueCollection>(jsonString); } catch { }
Error:
Cannot convert object of type 'System.String' to type 'System.Collections.Specialized.NameValueCollection'
Where am I making a mistake?