Add plain JSON string encoding entry points (encodeJson) and docs/tests (v0.1.1)#4
Add plain JSON string encoding entry points (encodeJson) and docs/tests (v0.1.1)#4felipestanzani merged 1 commit intomainfrom
Conversation
- Introduced `JToon.encodeJson(String)` and `JToon.encodeJson(String, EncodeOptions)` methods for direct JSON string encoding to TOON format. - Centralized JSON parsing in `JsonNormalizer.parse(String)` to maintain separation of concerns. - Expanded README documentation to include new encoding methods and examples. - Added a comprehensive changelog to document notable changes and version history. - Implemented unit tests for JSON string encoding, covering various scenarios and error cases.
|
Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces a new JSON string encoding pathway to JToon. It adds Changes
Sequence DiagramsequenceDiagram
actor User
participant JToon
participant JsonNormalizer
participant MAPPER as ObjectMapper
participant ValueEncoder
User->>JToon: encodeJson(String json)
JToon->>JToon: encodeJson(json, DEFAULT_OPTIONS)
JToon->>JsonNormalizer: parse(json)
JsonNormalizer->>JsonNormalizer: validate non-blank
JsonNormalizer->>MAPPER: readTree(json)
MAPPER-->>JsonNormalizer: JsonNode
JsonNormalizer-->>JToon: JsonNode
JToon->>ValueEncoder: encodeValue(JsonNode, options)
ValueEncoder-->>JToon: TOON String
JToon-->>User: TOON String
Note over JsonNormalizer: Blank/Invalid JSON<br/>throws IllegalArgumentException
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR introduces convenience overloads to encode plain JSON strings directly to TOON, updates documentation with examples, centralizes JSON parsing, and adds tests. Version is bumped to 0.1.1.
Motivation
JsonNodefirst.JToonby delegating to a centralized utility.Changes
JToon.encodeJson(String json): StringJToon.encodeJson(String json, EncodeOptions options): StringJsonNormalizer.parse(String)with consistent validation and error handling.EncodeOptions(indent, delimiter, lengthMarker)encodeJson, including Java text block usage.API
JToon:encodeJson(String json)encodeJson(String json, EncodeOptions options)JsonNormalizer.parse(String)and encoding toValueEncoder.encodeValue(...).Behavior and Validation
IllegalArgumentExceptionfromJsonNormalizer.parse(String).encode(...)of equivalent structures.Breaking Changes
Documentation
Encode a plain JSON stringexample and explains delimiter options and length markers in context.encodeJsonoverloads.Testing
build/reports/tests/test.Versioning
Migration Guide
encode(JsonNode)with the new entry points:Checklist
Summary by CodeRabbit
New Features
encodeJson()methods to encode JSON strings directly to TOON format with optional encoding options and input validation.Documentation
Tests