@@ -87,6 +87,27 @@ public static Config fromProperties(ConfigOrigin origin, Properties properties)
8787 }
8888 } else {
8989 var field = (PathElement .Key ) element ;
90+ if (!(currentObject instanceof Map <?, ?>)) {
91+ var prev = (Object ) map ;
92+ for (int j = 0 ; j < i - 1 ; j ++) {
93+ if (parts .get (j ) instanceof PathElement .Key k ) {
94+ prev = ((Map <String , Object >) prev ).get (k .name ());
95+ } else if (parts .get (j ) instanceof PathElement .Index index ) {
96+ prev = ((List <Object >) prev ).get (index .index ());
97+ } else {
98+ throw new IllegalStateException ();
99+ }
100+ }
101+ var prevPath = parts .get (i - 1 );
102+ currentObject = new LinkedHashMap <String , Object >();
103+ if (prevPath instanceof PathElement .Key k ) {
104+ ((Map <String , Object >) prev ).put (k .name (), currentObject );
105+ } else if (prevPath instanceof PathElement .Index index ) {
106+ ((List <Object >) prev ).set (index .index (), currentObject );
107+ } else {
108+ throw new IllegalStateException ();
109+ }
110+ }
90111 var object = (Map <String , Object >) currentObject ;
91112 var currentValue = object .get (field .name ());
92113 if (currentValue == null ) {
@@ -105,7 +126,7 @@ public static Config fromProperties(ConfigOrigin origin, Properties properties)
105126 } else {
106127 if (i + 1 < parts .size ()) {
107128 currentObject = currentValue ;
108- } else {
129+ } else if (!( currentValue instanceof Map <?, ?>)) {
109130 object .put (field .name (), value );
110131 }
111132 }
0 commit comments