| Recommend this page to a friend! |
| Info | Documentation | Reputation | Support forum | Blog | Links |
| Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
| 2026-02-01 (21 days ago) | Not yet rated by the users | Total: Not yet counted | Not yet ranked | |||||
| Version | License | PHP version | Categories | |||
| toonparser 1.0 | MIT/X Consortium ... | 7 | Parsers, PHP 7 |
| Description | Author | |
This package can encode and decode values in the TOON (Token-Oriented Object Notation) format. |
Please read this document to learn how to encode and decode PHP variable value in the TOON format.
A lightweight, human-readable data serialization format and parser for PHP.
TOON is designed to be:
This library provides a full encoder/decoder for converting between PHP arrays, TOON format, and JSON.
Supports:
* Primitive values * Nested objects * Lists * Table-like arrays (row-based structured data)
Just include the ToonParser.php file:
require_once 'ToonParser.php';
TOON is a structured, indentation-based text format.
It supports:
config:
setting1: true
setting2: "value"
users[2]:
-
id: 1
name: Alice
-
id: 2
name: Bob
tags[3]:
- red
- green
- blue
users[2]{id,name,role}:
1,Alice,admin
2,Bob,user
$json = '{
"name": "Alice",
"active": true,
"roles": ["admin", "editor"]
}';
echo jsonToToon($json);
Output:
name: Alice
active: true
roles[2]:
- admin
- editor
$toon = '
user:
id: 1
name: "Alice Smith"
active: true
';
echo toonToJson($toon);
Output:
{
"user": {
"id": 1,
"name": "Alice Smith",
"active": true
}
}
ToonParserEncodes a PHP array into TOON format.
$parser = new ToonParser();
$toon = $parser->encode($data);
Parses a TOON string back into a PHP array.
$array = $parser->decode($toonData);
jsonToToon(string $json): stringConverts a JSON string into TOON.
toonToJson(string $toon): stringConverts TOON into formatted JSON.
| TOON | PHP |
| -------- | --------- |
| true | true |
| false | false |
| null | null |
| numbers | int/float |
| "text" | string |
Strings must be quoted only if they contain:
spaces , : { } [ ] newlines tabs
Begin with:
key[count]:
Items start with -.
Compact structured rows:
key[count]{col1,col2,col3}:
value1,value2,value3
The parser currently assumes valid TOON input. A strict validation mode can be added on request.
Pull requests are welcome. Please open an issue before adding major features.
MIT License ? Free for personal & commercial use.
TOON Parser was designed to provide a readable, predictable data format, bridging the simplicity of JSON and the clarity of indentation-based formats like YAML.
| File | Role | Description |
|---|---|---|
| Lic. | License text | |
| Doc. | Documentation | |
| Class | Class source |
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
| Version Control | Unique User Downloads | |||||||
| 100% |
|
| Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.