Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to deserialize a string format as show below:

C#
 
string s = "{\"Tbl_Name \":[[\"A01\"],[\"A02\"],[\"A03\"],[\"A04\"],[\"ALR\"],null]}";
 


The out result should be {"A01", "A02, ... "ALR"}.

Wish you can help.
Thanks.
Posted
Updated 6-Oct-15 2:46am
v2
Comments
kedar001 6-Oct-15 7:39am    
please check http://www.codeproject.com/Tips/79435/Deserialize-JSON-with-C
Andy Lanng 6-Oct-15 8:55am    
link as link Deserialize JSON with C#

There are no html helper buttons for comments but you can still write the html
F-ES Sitecore 6-Oct-15 9:27am    
Your main problem is that that's not JSON so JSON serialisers might not work. Having colons and brackets doesn't make something JSON.

1 solution

Using Json.NET you can also deserialize a JSON object into a .NET generic dictionary

C#
string s = @"{""Tbl_Name"":""[[A01],[A02],[ALR]]""}";
Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(s);
	
Console.WriteLine(values.Count);
Console.WriteLine(values["Tbl_Name"]);


I hope this would help you getting started
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900