Friday, May 17, 2024
Homepage · c#
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  7] [ 7]  / answers: 1 / hits: 16362  / 8 Years ago, thu, may 19, 2016, 12:00:00

I am using the built-in library JavaScriptSerializer to serialize and deserialize a multidimensional array.



It is stated in the MSDN that A multidimensional array is serialized as a one-dimensional array, and you should use it as a flat array.



I have tried to deserialize it, but kept getting Unable to cast object of type 'System.Double[]' to type 'System.Double[,,]'.



double[, ,] y = serializer.Deserialize<double[, ,]>(jsonMatrix);


Does this mean that i have re-construct it back manually ? If so, any solutions.


More From » c#

 Answers
8

If its serializes multi dimension array into flat array then you won't be able to de-serialize it back into multi dimension array.



Have a look at this thread, one of the solution uses Json.net to serialize and de-serialize multi dimension array.



How to deseralize json object that contains multidimensional array?


[#62108] Tuesday, May 17, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
naya

Total Points: 60
Total Questions: 87
Total Answers: 87

Location: Guam
Member since Fri, Jun 18, 2021
3 Years ago
;