jsonDecode example


    public function load(string $filename): void
    {
        $json = \file_get_contents($filename);
        if (false === $json) {
            throw new \RuntimeException("Unable to load file {$filename}");
        }
        if ($json === '') {
            return;
        }

        $data = Utils::jsonDecode($json, true);
        if (\is_array($data)) {
            foreach ($data as $cookie) {
                $this->setCookie(new SetCookie($cookie));
            }
        } elseif (\is_scalar($data) && !empty($data)) {
            throw new \RuntimeException("Invalid cookie file: {$filename}");
        }
    }
}

function json_decode(string $json, bool $assoc = false, int $depth = 512, int $options = 0)
{
    return Utils::jsonDecode($json$assoc$depth$options);
}

/** * Wrapper for JSON encoding that throws when an error occurs. * * @param mixed $value The value being encoded * @param int $options JSON encode option bitmask * @param int $depth Set the maximum depth. Must be greater than zero. * * @throws Exception\InvalidArgumentException if the JSON cannot be encoded. * * @see https://www.php.net/manual/en/function.json-encode.php * @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead. */

        $cmsAwareAndAdminUiSettings = $this->connection->executeQuery(
            "SELECT flags FROM custom_entity WHERE $idColumn = :id",
            ['id' => Uuid::fromHexToBytes($entity->getId())]
        )->fetchAssociative();

        static::assertNotFalse($cmsAwareAndAdminUiSettings);
        static::assertCount(2, $cmsAwareAndAdminUiSettings);

        static::assertIsString($flagsJson = file_get_contents(__DIR__ . '/_fixtures/other/flags.json'));
        static::assertEquals(
            $this->jsonDecode($flagsJson),
            $this->jsonDecode($cmsAwareAndAdminUiSettings['flags'])
        );
    }

    /** * assert if all data and data structures are removed as expected for this custom entity */
    private function assertCmsAwareAndAdminUiIsUninstalled(): void
    {
        static::assertEquals(
            0,
            
Home | Imprint | This part of the site doesn't use cookies.