FSharp.Json icon indicating copy to clipboard operation
FSharp.Json copied to clipboard

Support multidimensional arrays

Open dbarbashov opened this issue 5 years ago • 3 comments

For example,

let x : int[,] = Array2D.init 1 1 (fun _ _ -> 0)

dbarbashov avatar Apr 17 '19 14:04 dbarbashov

I will add support for these shortly. Stay tuned.

vsapronov avatar Apr 28 '19 05:04 vsapronov

@lkmfwe what are your thoughts regarding multidimensional arrays representation in JSON? How the should be represented in JSON? Currently I consider 2 options:

  1. Flat array of items
  2. Array of array of ... levels of nesting = number of dimensions

vsapronov avatar Apr 29 '19 02:04 vsapronov

I think 2nd option is more suitable, because its JSON has more information. Also, Newtonsoft.Json serializes multidimensional arrays exactly like that:

open Newtonsoft.Json

let x = JsonConvert.SerializeObject(Array2D.init 3 2 (fun i j -> (i+1)*(j+1)))
printfn "%s" x
// > "[[1,2],[2,4],[3,6]]"

dbarbashov avatar Apr 29 '19 07:04 dbarbashov