-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnested-structures.php
More file actions
42 lines (38 loc) · 1.07 KB
/
nested-structures.php
File metadata and controls
42 lines (38 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Example: Nested Structures
*
* Shows how TOON handles deeply nested data structures efficiently.
*/
$data = [
'organization' => [
'name' => 'Tech Corp',
'founded' => 2020,
'departments' => [
'engineering' => [
'head' => 'Bob Smith',
'team_size' => 50,
'projects' => ['Project A', 'Project B', 'Project C']
],
'marketing' => [
'head' => 'Carol White',
'team_size' => 20,
'campaigns' => ['Campaign 1', 'Campaign 2']
]
],
'locations' => [
'headquarters' => 'San Francisco',
'branches' => ['New York', 'London', 'Tokyo']
]
]
];
echo "=== Nested Structures ===" . PHP_EOL;
$toon = toon_encode($data);
echo $toon . PHP_EOL;
echo PHP_EOL . "=== Decoding back ===" . PHP_EOL;
$decoded = toon_decode($toon);
print_r($decoded);
// Verify round-trip
echo PHP_EOL . "Round-trip verification: ";
echo ($data === $decoded) ? "✅ PASS" : "❌ FAIL";
echo PHP_EOL;