-
Notifications
You must be signed in to change notification settings - Fork 136
Add newline-delimited WireType.JSONL (JSON Lines) alongside comma-separated WireType.JSON_ONLY
#1245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/tidy
Are you sure you want to change the base?
Conversation
…user defined vars
…be stricter by default
WireType.JSONL (JSON Lines) support to Chronicle Wire
- Add JSONLReadDocumentContext for JSON-specific document boundary parsing that doesn't rely on YAML-style markers - Add JSONLWriteDocumentContext to wrap each document in braces and add newlines between documents for proper JSONL format - Add jsonlMode flag to prevent methodWriter() from overwriting JSONL contexts when useTextDocuments() is called - Override methodWriter() in JSONWire to preserve JSONL contexts - Add tests for method reader streaming with JSONL format - Add interoperability test showing JSON_ONLY output can be read by JSONL - Update tests to use readingDocument() for proper document context handling Co-Authored-By: Claude Opus 4.5 <[email protected]>
WireType.JSONL (JSON Lines) support to Chronicle WireWireType.JSONL (JSON Lines) alongside comma-separated WireType.JSON_ONLY
- Add expected output values for JSONL in WireDumperTest - Add JSONL to special handling in WireTypeTest.testFromFile like JSON/JSON_ONLY Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ity; update pom.xml to disable default jar goal
|
tgd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well-implemented JSONL support with excellent test coverage. Approving with minor suggestions.
| @Override | ||
| public void close() { | ||
| super.close(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: This empty close() override just calls super.close() and can be removed - it adds no behavior.
| * objects, allowing for efficient manipulation and parsing. | ||
| */ | ||
| @SuppressWarnings("this-escape") | ||
| @SuppressWarnings({"this-escape", "deprecation"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Consider localizing the @SuppressWarnings("deprecation") to the specific method(s) that use deprecated APIs rather than suppressing it class-wide. This makes it clearer which code paths touch deprecated APIs.
| * @return this wire configured for JSONL | ||
| * @see <a href="https://jsonlines.org/">JSON Lines specification</a> | ||
| */ | ||
| public JSONWire useJsonlDocuments() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Consider adding a thread-safety note to the Javadoc, e.g.:
* <p>Thread safety: The returned wire instance is not thread-safe.This matches the documentation style in the test class.



This PR introduces newline-separated JSON Lines support via
WireType.JSONL, while keeping the existing comma-separated stream behaviour available viaWireType.JSON_ONLY.WireType.JSONLis intended for streaming/log-style use cases where each message is a complete JSON object on its own line ({...}\n{...}\n). It also adds a JSON-specific reader that can safely consume both JSONL and legacy comma-separated JSON streams.Motivation
WireType.JSON_ONLYcurrently emits a comma-separated JSON stream, which is awkward for line-oriented tooling and streaming pipelines. JSONL is a widely used convention that makes record boundaries explicit, supports incremental processing, and plays nicely with “tail -f”, log shippers, and batch ingestion.What changed
New
WireType.JSONLuseTypes(false)), and uses JSONL-friendly conventions.JSONWireJSONL mode (useJsonlDocuments)Adds a
jsonlModeflag to preserve JSONL contexts.Configures JSONL defaults:
useTypes(false)useLowerCaseEnums(true)(configurable)Overrides
methodWriter()in JSONL mode to avoid the parentuseTextDocuments()call overwriting the JSONL contexts.JSONLReadDocumentContextJSON-specific read context that finds document boundaries by tracking brace/array depth (and respecting JSON strings/escapes), rather than YAML markers.
Accepts both:
{...}\n{...}\n){...},{...},{...})Strips outer braces when presenting the document body to the reader (matching the existing “document wrapper” behaviour).
JSONLWriteDocumentContextEnsures each document is a complete JSON object:
{ ... }\nafter each documentProduces valid JSONL output for method writer streaming:
{"event":[...]}{"event":[...]}Lowercase enum serialisation
useLowerCaseEnums(boolean)and implements lowercase output for enums (including untyped enum values) without allocating new strings.Output format examples
Method writer (JSONL)
Object write note
Test plan
Added/expanded
JSONLTestwith streaming coverage:testMethodReaderStreamingJsonl– reads multiple newline-delimited eventstestMethodReaderCommaSeparatedJson– reads comma-separated JSON streamstestWriteJsonReadJsonl– verifiesWireType.JSON_ONLYoutput is readable by the JSONL readertestWriteJsonlReadJson– verifies JSONL round-tripExisting JSONL suite: 33 tests pass (1 skipped)
mvn -Dtest=JSONLTest testCompatibility
WireType.JSON_ONLYbehaviour remains unchanged.WireType.JSONLprovides a line-oriented alternative and a reader tolerant of both newline and comma delimiters, easing migration and mixed-stream handling.