Md. Parvez Alam Md. Parvez Alam - 1 month ago 10x
JSON Question

Single string in json to deserialze c#

I have following string in JSON

string IDS = "{\"IDS\":\"23,24,25,28\"}"

Now I need to convert this into c# string

I tried this

string id = new JavaScriptSerializer().Deserialize<string>(IDS);

I want to get back this comma separated string in a string, but it throws error

No parameterless constructor defined for type of 'System.String

Any help what to do ?



It's because your json string is a Dictionary. Try it with something like this

var result = new JavaScriptSerializer().Deserialize<Dictionary<string, string>>(IDS);
var mystring = result["IDS"];