Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Multidimensional Arrays converted this way? #116

Open
bqio opened this issue Aug 30, 2020 · 2 comments
Open

Why Multidimensional Arrays converted this way? #116

bqio opened this issue Aug 30, 2020 · 2 comments

Comments

@bqio
Copy link

bqio commented Aug 30, 2020

var circles = new Circle[]
{
  new Circle() { Center = new Point(0, 0), Radius = 1, data = new int [2, 3] { { 1, 2, 4 }, { 1, 2, 3 } } },
  new Circle() { Center = p, Radius = 2 },
  new Circle() { Center = p, Radius = 3 }
};

var json = JSON.ToNiceJSON(circles);
var data = JSON.ToObject<Circle[]>(json);
[
   {
      "Center" : {
         "X" : 0,
         "Y" : 0
      },
      "Radius" : 1,
      "data" : [
         1,
         2,
         4,
         1,
         2,
         3
      ]
   },
   {
      "Center" : {
         "X" : 0,
         "Y" : 1
      },
      "Radius" : 2,
      "data" : null
   },
   {
      "Center" : {
         "X" : 0,
         "Y" : 1
      },
      "Radius" : 3,
      "data" : null
   }
]

After the reverse transformation, data = int [6], but need int [2, 3].

@mgholam
Copy link
Owner

mgholam commented Aug 30, 2020

Probably a problem with serializing multi-dimensional arrays... I will look into it, thanks!

@mgholam
Copy link
Owner

mgholam commented Sep 1, 2020

The IEnumerable just goes though the list regardless, I have to use the Rank property.
How is the following as an output :

"data" : [ [1,2,4] , [1,2,3] ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants