You are viewing documentation for an outdated version. It is no longer supported!

Json

The \Aedart\Utils\Json component offers a few JSONopen in new window utilities. Among such, it wraps PHP's native json_encode()open in new window and json_decode()open in new window.

Encoding and Decoding

Using the encode() and decode() methods, you ensure that the JSON_THROW_ON_ERRORopen in new window bitmask option is automatically set. This means that encoding or decoding should fail, the native \JsonException open in new window is thrown.

use Aedart\Utils\Json;

$encoded = Json::encode([
    'name'  => 'Reilly',
    'age'   => 32
]);

// ------------------------------------------ //

$decoded = Json::decode('{"name":"Michele Rodriguez","age":4}');