Skip to content

Bug: Encoder output cannot be decoded by own decoder (indentation mismatch)Β #50

Description

@acc0mplish

Bug Description

The encoder creates TOON output that fails to parse with the decoder due to indentation mismatch.

Steps to Reproduce

# Encode JSON to TOON
echo '{"questions":[{"question":"λ°±μ—”λ“œ","header":"λ°±μ—”λ“œ","options":[{"label":"FastAPI","description":"Python"},{"label":"Django","
description":"Python"}],"multiSelect":false}]}' | toon

# Output (generated by encoder):
questions[1]:
  - question: λ°±μ—”λ“œ
    header: λ°±μ—”λ“œ
    options[2]{label,description}:
    FastAPI,Python
    Django,Python
    multiSelect: false

# Try to decode the same output
echo 'questions[1]:
  - question: λ°±μ—”λ“œ                                                                                                                
    header: λ°±μ—”λ“œ
    options[2]{label,description}:
    FastAPI,Python
    Django,Python
    multiSelect: false' | toon --decode

Error

Error: Parse error at line 5, column 12: Invalid indentation for tabular row: expected 6 spaces, found 4

Expected Behavior

The encoder output should be decodable by the decoder (round-trip compatibility).

Environment

- Rust: 1.92.0
- toon-format: 0.4.1
- OS: WSL2 (Linux)

Proposed Fix

The encoder and decoder should agree on indentation rules for tabular rows. Either:
1. Fix encoder to use 6 spaces for tabular rows
2. Fix decoder to accept 4 spaces for tabular rows

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions