High-performance JSON extension for PHP written in Rust.
A blazing-fast JSON extension for PHP that provides drop-in replacements for json_decode() and json_encode() better performance and clean exception-based error handling.
<?php
use Elephant\Json\Json;
// Decode JSON with exceptions
try {
$data = Json::decode('{"name": "Elephant", "speed": "fast"}');
echo $data['name']; // "Elephant"
} catch (Elephant\Json\JsonException $e) {
echo "JSON error: " . $e->getMessage();
}
// Encode to JSON
$data = [
'message' => 'hello world',
'code' => 1122,
'isAdmin' => true
];
$json = Json::encode($data);
// Result: {"message":"hello world","code":1122,"isAdmin":true}
// Validate JSON
if (Json::validate($invalidJson)) {
// JSON is valid
}