Reputation: 5031
I have a very odd JSON array as follows
[["1","hello"],["2","hello2"],["3","hello3"],["",""],["",""],[null,null],[null,null],[null,null],[null,null],[null,null]]
I need to de-serialize in c# but there doesn't seem to be anything common to convert it to I tried string but then I get the follow error:
Type string is not supported for deserialization of an array.
This is the code I tried:
string jsonString = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<string>(json);
How would you get at the strings in the JSON?
Upvotes: 0
Views: 128
Reputation: 6030
You could deserialize it to an array of string arrays:
string[][] jsonString = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<string[][]>(json);
Or maybe a list of string-tuples (Dictionary could be problematic due to the lack of unique keys):
List<Tuple<string, string>> jsonString = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialze<List<Tuple<string, string>>(json);
Upvotes: 2