Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hi All,
 
I have a two dimensional array in java script like
var exArray = [[2, 3], [3, 4], [5, 6]];
These array values are stored in a hidden variable using json object.
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 9-Oct-12 0:48am
Edited 9-Oct-12 1:45am
v3

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
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.
  Permalink  
v2
Comments
Narra sreenu at 9-Oct-12 7:02am
   
how to deserialise json object into two dimensional array.
Zoltán Zörgő at 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)

  Print Answers RSS
0 OriginalGriff 235
1 Sergey Alexandrovich Kryukov 120
2 Richard MacCutchan 100
3 ChauhanAjay 95
4 BotCar 95
0 Sergey Alexandrovich Kryukov 9,056
1 OriginalGriff 8,041
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 9 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100