Supported Versions: PHP 5 >= 5.2.0, PHP 7, PHP 8, PECL json >= 1.2.0
Decodes a JSON string
<?php json_decode( string $json, ?bool $associative = null, int $depth = 512, int $flags = 0): mixed
<?php 'console',
];
$regions = json_decode(file_get_contents(__DIR__ . '/regions.json'), true);
$export = [];
foreach ($regions as $region) {
<?php $regions = [$singleRegion];
} else {
$regions = json_decode(file_get_contents(__DIR__ . '/regions.json'), true);
}
<?php $region = $input->getArgument('region');
$layersJson = file_get_contents(dirname(__DIR__, 3) . '/layers.json');
$layers = json_decode($layersJson, true, 512, JSON_THROW_ON_ERROR);
$io->title("Layers for the $region region");
$array = [];
<?php }
try {
$event = $data ? json_decode($data, true, 512, JSON_THROW_ON_ERROR) : null;
} catch (JsonException $e) {
throw new Exception('The JSON provided for the event data is invalid JSON.');
}
<?php public function getData(): array
{
return json_decode(base64_decode($this->getRawData()), true);
}
public function getEventName(): string
<?php 'Payload' => $event ?? '',
]);
$resultPayload = json_decode($rawResult->getPayload(), true);
$invocationResult = new InvocationResult($rawResult, $resultPayload);
$error = $rawResult->getFunctionError();
<?php throw new Exception('Failed to determine the Lambda invocation ID');
}
$event = json_decode($body, true);
return [$event, $context];
}
<?php {
public function test_connect()
{
$event = json_decode(file_get_contents(__DIR__ . '/Samples/websocket-connect.json'), true);
$event = new WebsocketEvent($event);
$this->assertSame('CONNECT', $event->getEventType());
<?php public function test_disconnect()
{
$event = json_decode(file_get_contents(__DIR__ . '/Samples/websocket-disconnect.json'), true);
$event = new WebsocketEvent($event);
$this->assertSame('DISCONNECT', $event->getEventType());
<?php public function test_message()
{
$event = json_decode(file_get_contents(__DIR__ . '/Samples/websocket-message.json'), true);
$event = new WebsocketEvent($event);
$this->assertSame('MESSAGE', $event->getEventType());
<?php public function test_canonical_case()
{
$event = json_decode(file_get_contents(__DIR__ . '/dynamodb.json'), true);
$keys = ['Id' => ['N' => '101']];
$newImage = [
'Message' => ['S' => 'New item!'],
<?php public function test_old_image()
{
$event = json_decode(file_get_contents(__DIR__ . '/dynamodb.json'), true);
$keys = ['Id' => ['N' => '101']];
$newImage = [
'Message' => ['S' => 'New item!'],
<?php public function test_new_and_old_images()
{
$event = json_decode(file_get_contents(__DIR__ . '/dynamodb.json'), true);
$keys = ['Id' => ['N' => '101']];
$newImage = [
'Message' => ['S' => 'This item has changed'],
<?php public function test_keys_only()
{
$event = json_decode(file_get_contents(__DIR__ . '/dynamodb.json'), true);
$keys = ['Id' => ['N' => '101']];
$eventName = 'REMOVE';
<?php {
public function test canonical case()
{
$json = json_decode(file_get_contents(__DIR__ . '/eventbridge.json'), true);
$event = new EventBridgeEvent($json);
$this->assertSame('53dc4d37-cffa-4f76-80c9-8b7d4a4d2eaa', $event->getId());