public void ToCollectionsNestedTest() { JsonArray ja = JsonValue.Parse("[1, {\"A\":[1,2,3]}, 5]") as JsonArray; JsonObject jo = JsonValue.Parse("{\"A\":1,\"B\":[1,2,3]}") as JsonObject; object[] objArray = ja.ToObjectArray(); Assert.NotNull(objArray); Assert.Equal <int>(ja.Count, objArray.Length); Assert.Equal((int)ja[0], (int)objArray[0]); Assert.Equal((int)ja[2], (int)objArray[2]); IDictionary <string, object> dict = objArray[1] as IDictionary <string, object>; Assert.NotNull(dict); objArray = dict["A"] as object[]; Assert.NotNull(objArray); for (int i = 0; i < 3; i++) { Assert.Equal(i + 1, (int)objArray[i]); } dict = jo.ToDictionary(); Assert.NotNull(dict); Assert.Equal <int>(jo.Count, dict.Count); Assert.Equal <int>(1, (int)dict["A"]); objArray = dict["B"] as object[]; Assert.NotNull(objArray); for (int i = 1; i < 3; i++) { Assert.Equal(i + 1, (int)objArray[i]); } }