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

Are multi dimensional arrays supported? #326

Open
kevin-marshall opened this issue Mar 24, 2019 · 0 comments
Open

Are multi dimensional arrays supported? #326

kevin-marshall opened this issue Mar 24, 2019 · 0 comments

Comments

@kevin-marshall
Copy link

kevin-marshall commented Mar 24, 2019

I created a simple test case and multi dimensional arrays don't appear to be supported. Is there any plan to support them?

static void Main(string[] args)
        {
            IDictionary<string, dynamic> dict = new Dictionary<string, dynamic>();
            dict["String"] = "Hello World";
            dict["Int"] = 1;
            dict["Double"] = 7.0;
            List<Double> double_array = new List<double>() { 1.0, 2.0, 3.0 };
            dict["Array Double"] = double_array;

            double[,] multi_dimensional_array = new double[2, 3];
            multi_dimensional_array[0,0] = 1.0;
            multi_dimensional_array[0,0] = 2.0;
            multi_dimensional_array[0,0] = 3.0;

            multi_dimensional_array[1,0] = 4.0;
            multi_dimensional_array[1,0] = 5.0;
            multi_dimensional_array[1,0] = 6.0;
            dict["Multi Dimensional Array"] = multi_dimensional_array;

            List<IDictionary<string, dynamic>> object_list = new List<IDictionary<string, dynamic>>
            {
                new Dictionary<string, dynamic>() { { "Hello World 1", 1.0 }, { "Hello World 2", 2.0 } }
            };
            dict["Object Array"] = object_list;

            dict["Object"]  = new Dictionary<string, dynamic>() { { "Object 1", 1.0 }, { "Object 2", 2.0 } };

            object obj = dict;
            string json = Jil.JSON.Serialize(obj, Jil.Options.PrettyPrint);
            object root = Jil.JSON.Deserialize<Dictionary<string, dynamic>>(json);

            /*
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\tmp\jil.json"))
            {
                Jil.JSON.Serialize(hash, file, Jil.Options.PrettyPrint);
            }*/
        }

Also, another issue which took me a while to figure out is the Jil.JSON.Serialize behaves differently if I pass dict as the parameter. The value references aren't converted.

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

1 participant