Skip to content

elephant-php/json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🐘 Elephant JSON

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
}

About

PHP extension for simple JSON encoding and decoding

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages