Click here to Skip to main content
15,939,960 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a two dimensional array in java script like
C#
var exArray = [[2, 3], [3, 4], [5, 6]];

These array values are stored in a hidden variable using json object.
C#
document.getElementById("hdnArray").value = JSON.stringify(exArray);

In Code side,
the hidden variable value return as "[[2, 3], [3, 4], [5, 6]]".

Now I want to convert these hidden variable value into two dimensional array without using spliting operation.
Posted
Updated 9-Oct-12 1:45am
v3

1 solution

If it is json encoded, you can use the same approach in c# also. Use a json deserializer.

[Update]
Depending on what you want to do with it, a simple method is using FastJson[^] for example:
C#
var newobj = fastJSON.JSON.Instance.Parse(@"[[2, 3], [3, 4], [5, 6]]");

You will get a List<list<object>> where every element will be an Int64. I am not sure, that converting this to array is really necessary.
 
Share this answer
 
v2
Comments
Narra sreenu 9-Oct-12 7:02am    
how to deserialise json object into two dimensional array.
Zoltán Zörgő 9-Oct-12 7:30am    
See my update

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