Skip to content

Decoder corrupts quoted strings with colons in expanded primitive arrays #13

Description

@RahulGopathi

Bug Summary

In an expanded primitive array (spec §9.4), items whose string value contains a colon are silently parsed as one-key objects instead of as strings. No exception is raised.

The canonical TypeScript reference (@toon-format/toon) handles the same input correctly.

Steps to Reproduce

  1. Decode a TOON document containing key[N|]: with - "<string-with-colon>" items underneath.

Expected Behavior

Per spec §9.3, disambiguation between key-value lines and primitive items uses unquoted colons. A quoted string like "a:b" is a primitive, not an object.

{"items": ["a:b", "c:d"]}

Actual Behavior

{"items": [{'"a': 'b"'}, {'"c': 'd"'}]}

Code Example

import toons

toons.loads('''items[2|]:
  - "a:b"
  - "c:d"
''')

Environment

  • TOONS version: 0.5.5
  • Python version: 3.12
  • OS: macOS arm64 (also reproduces on manylinux_x86_64)

Additional Context

Relevant spec section: §9.4 Mixed / Non-Uniform Arrays — Expanded List — defines - <primitive> as a valid item form for expanded list arrays.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions