0
votes

I have the following JSON which is successfully posted via AJAX as a string to a method.

"[[\"d1\",1,0],[\"d2\",1,1],[\"d3\",1,2],[\"d4\",1,3],[\"d5\",2,0],[\"d6\",2,1],[\"d7\",2,2],[\"d8\",2,3],[\"d9\",3,0],[\"d10\",3,1],[\"d11\",3,2],[\"d12\",3,3],[\"d13\",4,0],[\"d14\",4,1],[\"d15\",4,2],[\"d16\",4,3]]"

I can't figure out how to deserialize these arrays. I've tried:

JsonConvert.DeserializeObject(jsonData);
JsonConvert.DeserializeObject<string[]>(jsonData);

I don't have any control over what is being posted back.

1

1 Answers

1
votes

I am a little unclear on the data as it appears to be an array of arrays, each internal array being one string followed by two integers. I have started using ServiceStack for my JSON parsing, but Newtonsoft should work just as well.

Try using:

JsonConvert.DeserializeObject<string[][]>()

and see if you get an array of string arrays. If not try using ServiceStack:

JsonReader<string[][]>.Parse(jsonData)