Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Response.php

function Response::toArray

File

vendor/symfony/browser-kit/Response.php, line 91

Class

Response
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\BrowserKit

Code

public function toArray() : array {
    if (isset($this->jsonData)) {
        return $this->jsonData;
    }
    try {
        $content = json_decode($this->content, true, flags: \JSON_BIGINT_AS_STRING | \JSON_THROW_ON_ERROR);
    } catch (\JsonException $e) {
        throw new JsonException($e->getMessage(), $e->getCode(), $e);
    }
    if (!\is_array($content)) {
        throw new JsonException(\sprintf('JSON content was expected to decode to an array, "%s" returned.', get_debug_type($content)));
    }
    return $this->jsonData = $content;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal