Data-TOON

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN


        name: Alice
        quote: "She said \"Hello\""

- **Number** - Integer or float (canonicalized)

        count: 42
        ratio: 3.14

- **Boolean** - true or false

        active: true
        deleted: false

- **Null** - Null value

        optional_field: null

## Delimiters

Three delimiter options for array values:

**Comma (default):**
    data\[3\]: a,b,c

**Tab:**
    data\[3<TAB>\]: a<TAB>b<TAB>c

**Pipe:**
    data\[3|\]: a|b|c

Use tab or pipe delimiters when values might contain commas.

## String Escaping

Standard escape sequences are supported:

    text: "Line 1\nLine 2"
    path: "C:\\Program Files\\App"
    json: "Use \" to escape quotes"

## Root Forms

Documents can start with different root types:

    # Root object (default)
    name: Alice
    age: 30

    # Root primitive
    42
    
    # Root array
    [3]: a,b,c

# PERFORMANCE CONSIDERATIONS

- Encoding is O(n) in data size
=item \* Decoding is O(n) in text size
=item \* Memory usage is proportional to data complexity
=item \* Large documents (>100MB) may require streaming parser

# SECURITY

Data::TOON includes several security features:

- **Depth Limiting** - Prevents stack overflow from deeply nested structures
    Default max\_depth: 100 levels
    Configurable via encode/decode options
- **Circular Reference Detection** - Prevents infinite loops during encoding
    Automatically detects and rejects circular references
- **Input Validation** - Strict parsing rules prevent injection attacks
    All strings are treated as literal values
    No code evaluation or command injection possible

# COMPATIBILITY

- Perl 5.14 or later
=item \* No external dependencies
=item \* Pure Perl implementation (portable)

# TOON SPECIFICATION COMPLIANCE

This implementation achieves 95%+ compliance with TOON Specification v1.0:

✓ Complete object support
✓ Complete array support (all 3 formats)
✓ All delimiters (comma, tab, pipe)
✓ Root forms (object, array, primitive)
✓ String escaping
✓ Canonical number form
✓ Security measures
✓ Full type inference

See [TOON Specification](https://github.com/toon-format/spec/blob/main/SPEC.md) for complete specification.

# COMMON ERRORS AND TROUBLESHOOTING

## "Maximum nesting depth exceeded"

If you encounter this error, your data is nested more than 100 levels deep:

    # Increase max_depth
    my $encoded = Data::TOON->encode($data, max_depth => 200);

## "Circular reference detected"

Your data structure contains a reference to itself:

    my $obj = { name => 'Alice' };
    $obj->{self} = $obj;  # This creates a circle!

Solution: Remove the circular reference before encoding.

## Inconsistent type inference

If values aren't being parsed as expected, use explicit quoting:

    # Without quotes - might be interpreted as number
    value: 42
    



( run in 1.705 second using v1.01-cache-2.11-cpan-39bf76dae61 )