@@ -58,7 +58,8 @@ private JsonObject navigateToNode(String path) {
5858 if (current .has (parts [0 ]) && current .get (parts [0 ]).isJsonObject ()) {
5959 return current .getAsJsonObject (parts [0 ]);
6060 } else {
61- //System.out.println("navigateToNode: Invalid path component (single-path): " + parts[0]);
61+ // System.out.println("navigateToNode: Invalid path component (single-path): " +
62+ // parts[0]);
6263 return null ;
6364 }
6465 }
@@ -69,7 +70,7 @@ private JsonObject navigateToNode(String path) {
6970 if (element != null && element .isJsonObject ()) {
7071 current = element .getAsJsonObject ();
7172 } else {
72- //System.out.println("navigateToNode: Invalid path component: " + parts[i]);
73+ // System.out.println("navigateToNode: Invalid path component: " + parts[i]);
7374 return null ;
7475 }
7576 }
@@ -84,7 +85,7 @@ private JsonObject ensureParentObjectsExist(String path) {
8485
8586 // Iterate through path parts except the last part, which is the actual key
8687 for (int i = 0 ; i < parts .length - 1 ; i ++) {
87- if (!current .has (parts [i ]) || !current .get (parts [i ]).isJsonObject ()) {
88+ if (!current .has (parts [i ]) || current . get ( parts [ i ]) == null || !current .get (parts [i ]).isJsonObject ()) {
8889 // Create a new JsonObject if none exists or it's not an object
8990 current .add (parts [i ], new JsonObject ());
9091 }
@@ -146,7 +147,8 @@ public List<String> getKeys(String path) {
146147 return keys ;
147148 }
148149
149- //System.out.println("getKeys: No valid keys found for path = " + path + ". Make sure the path is correct.");
150+ // System.out.println("getKeys: No valid keys found for path = " + path + ".
151+ // Make sure the path is correct.");
150152 return new ArrayList <>();
151153 }
152154
@@ -163,7 +165,7 @@ public JsonElement getNode(String path) {
163165 return parentNode .get (lastPart );
164166 }
165167
166- //System.out.println("getNode: Could not find element for path = " + path);
168+ // System.out.println("getNode: Could not find element for path = " + path);
167169 return null ;
168170 }
169171
0 commit comments