Example #1
0
        public static void ObjectTree()
        {
            string json = @"{""MyIntMissing"":2, ""MyReference"":{""MyIntMissingChild"":3}}";

            ClassWithReference obj = JsonSerializer.Parse <ClassWithReference>(json);

            Assert.IsType <JsonElement>(obj.MyOverflow["MyIntMissing"]);
            Assert.Equal(1, obj.MyOverflow.Count);
            Assert.Equal(2, obj.MyOverflow["MyIntMissing"].GetInt32());

            ClassWithExtensionProperty child = obj.MyReference;

            Assert.IsType <JsonElement>(child.MyOverflow["MyIntMissingChild"]);
            Assert.IsType <JsonElement>(child.MyOverflow["MyIntMissingChild"]);
            Assert.Equal(1, child.MyOverflow.Count);
            Assert.Equal(3, child.MyOverflow["MyIntMissingChild"].GetInt32());
        }