@Test
    public void test_that_nested_structs_are_formatted_to_json() {
        StructtypesConfig.Builder builder = new StructtypesConfig.Builder();
        StructtypesConfig.Nested.Builder nestedBuilder = new StructtypesConfig.Nested.Builder();
        StructtypesConfig.Nested.Inner.Builder innerBuilder = new StructtypesConfig.Nested.Inner.Builder();
        innerBuilder.name("foo");
        innerBuilder.emails("Ulf Lilleengen@foo");
        innerBuilder.emails("Ulf Lilleengen@bar");
        innerBuilder.gender(StructtypesConfig.Nested.Inner.Gender.Enum.MALE);
        nestedBuilder.inner(innerBuilder);
        builder.nested(nestedBuilder);
        StructtypesConfig.Nestedarr.Builder nestedArrBuilder = new StructtypesConfig.Nestedarr.Builder();
        StructtypesConfig.Nestedarr.Inner.Builder innerNestedArrBuilder = new StructtypesConfig.Nestedarr.Inner.Builder();
        innerNestedArrBuilder.emails("foo@bar");
        innerNestedArrBuilder.name("bar");
        innerNestedArrBuilder.gender(StructtypesConfig.Nestedarr.Inner.Gender.Enum.FEMALE);
        nestedArrBuilder.inner(innerNestedArrBuilder);
        builder.nestedarr(nestedArrBuilder);

        final StructtypesConfig config = new StructtypesConfig(builder);
        final String expectedJson = inputJson(
                "{",
                "    'complexarr': [],",
                "    'nested': {",
                "        'inner': {",
                "            'emails': [",
                "                'Ulf Lilleengen@foo',",
                "                'Ulf Lilleengen@bar'",
                "            ],",
                "            'gender': 'MALE',",
                "            'name': 'foo'",
                "        }",
                "    },",
                "    'nestedarr': [",
                "        {",
                "            'inner': {",
                "                'emails': [",
                "                    'foo@bar'",
                "                ],",
                "                'gender': 'FEMALE',",
                "                'name': 'bar'",
                "            }",
                "        }",
                "    ],",
                "    'simple': {",
                "        'emails': [],",
                "        'gender': 'MALE',",
                "        'name': '_default_'",
                "    },",
                "    'simplearr': []",
                "}"
        );

        assertConfigEquals(expectedJson, config);
    }
@author Ulf Lilleengen
@author Vegard Sjonfjell
config/src/test/java/com/yahoo/config/subscription/ConfigInstanceSerializerTest.java