Skip to content

Conversation

@Asintotoo
Copy link

Description

Adds a decodeToMap method as a wrapper around decode(String) and decode(String, DecodeOptions) that directly parses a string into a Map<String, Object>. No manual casting is required. If the result is null or invalid, an empty map is returned.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Related Issues

Closes #

Changes Made

  • added JToon.decodeToMap(String, DecodeOptions) method
  • added JToon.decodeToMap(String) method

SPEC Compliance

  • This PR implements/fixes spec compliance
  • Spec section(s) affected:
  • Spec version:

Testing

  • All existing tests pass
  • Added new tests for changes
  • Tested on Java 17
  • Tested on Java 21

Test Output

# Paste test output here

Code Quality

  • Ran ./gradlew test - all tests pass
  • Ran ./gradlew jacocoTestCoverageVerification - coverage meets 85% threshold
  • Added JavaDoc comments for public APIs
  • Code follows Java conventions

Checklist

  • My code follows the project's coding standards
  • I have added JavaDoc comments to new public APIs
  • I have added JUnit tests that prove my fix/feature works
  • New and existing tests pass locally
  • I have updated documentation (README.md if needed)
  • My changes do not introduce new dependencies (or are justified)
  • I have maintained Java 17+ compatibility
  • I have reviewed the TOON specification for relevant sections

Performance Impact

  • No performance impact
  • Performance improvement (describe below)
  • Potential performance regression (describe and justify below)

Breaking Changes

  • No breaking changes
  • Breaking changes (describe migration path below)

Screenshots / Examples

String toon = """
           id: 123
           name: Ada
           active: true
           """;
 Map<String, Object> map = JToon.decodeToMap(toon);

Output:

{ id=123, name=Ada, active=true }

Additional Context

Checklist for Reviewers

  • Code changes are clear and well-documented
  • Tests adequately cover the changes
  • Documentation is updated
  • No security concerns
  • Follows TOON specification
  • Backward compatible (or breaking changes are justified and documented)

@Asintotoo Asintotoo requested a review from a team as a code owner November 22, 2025 11:57
import static org.junit.jupiter.api.Assertions.*;

@Tag("unit")
public class JToonDecodeToMapTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are lacking nesting examples. The edge cases must also be considered.

@felipestanzani
Copy link
Collaborator

Could you make your review, @jenspapenhagen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants