0

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?

1
  • What are you using to deserialize? Have you tried taking a look at json.net? Commented Jan 20, 2015 at 11:18

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

1 Comment

Ah your on to something that's a massive help, thanks :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.