This file is for contributor/agent operational notes. Read json-java21-jdt/README.md for purpose, supported syntax, and user-facing examples.
JDT stands for "JSON Document Transforms" -- a C# technology from Microsoft that we are porting to Java. It has NOTHING to do with Eclipse JDT (Java Development Tools). There are NO Eclipse files in this module. Do not confuse json-java21-jdt with Eclipse tooling. Every file in this module relates exclusively to JSON Document Transforms.
- User docs MUST recommend only
./mvnw. - The
$(command -v mvnd || command -v mvn || command -v ./mvnw)wrapper is for local developer speed only; do not put it in user-facing docs.
json-java21-jdt/src/main/java/json/java21/jdt/Jdt.java-- Public API:Jdt.transform(source, transform)json-java21-jdt/src/main/java/json/java21/jdt/JdtException.java-- Exception for invalid transforms
json-java21(core): TheJsonValuesealed type hierarchy (jdk.sandbox.java.util.json.*)json-java21-jsonpath:JsonPath.parse(path).query(source)for@jdt.path-based operations
Both are compile-time dependencies. Changes to either module's public API may require updates here.
The engine currently has no AST. It works directly on JsonValue trees, interpreting @jdt.* keys on-the-fly via a recursive static-method walker:
Jdt.transform(source, transform)-- public entry pointapplyTransform(source, transform)-- dispatches: non-object replaces, object checks for@jdt.*directivesapplyJdtDirectives(source, transformObj)-- applies verbs in order: Rename -> Remove -> Merge -> Replace- Non-JDT keys in the transform object are processed as recursive default-merge operations
Path operations follow the pattern:
- Parse JSONPath string:
JsonPath.parse(pathString) - Query source:
jsonPath.query(source)returnsList<JsonValue> - Transform matched nodes using reference identity (
node == match) to find and replace
Known limitation: Reference identity matching is fragile. It works only because JsonPath returns the exact same object instances from the source tree (not copies).
- Path-based rename:
applyRenameWithPathis a stub (returns source unchanged). The TODO is atJdt.java:234. - ~20 skipped Microsoft fixtures: All path-based operation fixtures are in
Skipped/subdirectories.
| Directive | Method | Notes |
|---|---|---|
@jdt.rename |
applyRename -> applyRenameMapping / applyRenameWithPath |
Path-based is a stub |
@jdt.remove |
applyRemove -> removeKey / applyRemoveWithPath |
Path-based uses removeMatchedNodes |
@jdt.merge |
applyMerge -> mergeObjects / applyMergeWithPath |
Supports double-bracket arrays |
@jdt.replace |
applyReplace -> applyReplaceWithPath |
Supports double-bracket arrays |
Microsoft JDT fixtures are vendored into:
json-java21-jdt/src/test/resources/microsoft-json-document-transforms/Inputs/
Convention: {Category}.Source.json + {TestName}.Transform.json + {TestName}.Expected.json
Fixtures in Skipped/ subdirectories are excluded by MicrosoftJdtFixturesTest (line 42 filter). Move fixtures out of Skipped/ as path-based operations are implemented.
- Update
Jdt.java(the engine). - Add unit tests in
JdtTest.javafor the new behavior. - Move applicable fixtures from
Skipped/to the active directory if path-based operations are now supported. - New tests MUST extend
JdtLoggingConfig. - Verify the full build passes: test counts in
.github/workflows/ci.ymlmust match.
The planned evolution follows the same pattern as jtd-esm-codegen:
- Parse the transform JSON into a sealed JDT AST (algebraic data types)
- Walk the AST with exhaustive switch expressions to generate code
- Bytecode codegen: Compile JDT transforms into generated Java classes
- ESM codegen: Generate ES2020 JavaScript modules from the JDT AST
- Compiled JSONPath: Replace the static JsonPath walker with compiled functions
This aligns with the project-wide "AST -> codegen" metaprogramming pattern.