Skip to content

Commit d9e5964

Browse files
cursoragentsimbo1905
andcommitted
Issue #130 Fix default recursion skip, merge replacement, and relative path normalization
Co-authored-by: simbo1905 <simbo1905@60hertz.com>
1 parent f2f0976 commit d9e5964

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

json-transforms/src/main/java/json/java21/transforms/TransformRunner.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ private static JsonValue applyMergeValueToMatched(JsonValue matched, TransformAs
228228
final var applied = processTransform(obj, tov.compiled(), isDocumentRootForMatch);
229229
yield applied.value();
230230
}
231-
yield matched;
231+
// Merge-with-attributes replaces mismatched types (including primitive -> object).
232+
yield tov.rawObject();
232233
}
233234
};
234235
}
@@ -240,7 +241,9 @@ private static JsonObject applyDefault(JsonObject source, Map<String, JsonValue>
240241
final var key = entry.getKey();
241242
final var tVal = entry.getValue();
242243

243-
if (recursedKeys.contains(key) && current.members().get(key) instanceof JsonObject && tVal instanceof JsonObject) {
244+
// Mirror the reference implementation: nodes already recursed into are removed from the transform
245+
// before default processing, so default must never re-process them.
246+
if (recursedKeys.contains(key)) {
244247
continue;
245248
}
246249

json-transforms/src/main/java/json/java21/transforms/TransformSyntax.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ static String normalizePathString(String path) {
3131
if (trimmed.startsWith("@")) {
3232
return "$" + trimmed.substring(1);
3333
}
34-
return trimmed;
34+
if (trimmed.startsWith("$")) {
35+
return trimmed;
36+
}
37+
if (trimmed.startsWith(".") || trimmed.startsWith("[")) {
38+
return "$" + trimmed;
39+
}
40+
// Json.NET SelectTokens accepts bare property names; treat them as relative paths.
41+
return "$." + trimmed;
3542
}
3643
}
3744

0 commit comments

Comments
 (0)