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

Breadcrumb

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

function JsonEncoder::__construct

Same name in this branch
  1. 11.1.x vendor/symfony/serializer/Encoder/JsonEncoder.php \Symfony\Component\Serializer\Encoder\JsonEncoder::__construct()

Overrides JsonEncoder::__construct

File

core/modules/serialization/src/Encoder/JsonEncoder.php, line 28

Class

JsonEncoder
Adds 'ajax' to the supported content types of the JSON encoder.

Namespace

Drupal\serialization\Encoder

Code

public function __construct(?JsonEncode $encodingImpl = NULL, ?JsonDecode $decodingImpl = NULL) {
    // Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be
    // embedded into HTML.
    // @see \Symfony\Component\HttpFoundation\JsonResponse
    $json_encoding_options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT;
    $this->encodingImpl = $encodingImpl ?: new JsonEncode([
        JsonEncode::OPTIONS => $json_encoding_options,
    ]);
    $this->decodingImpl = $decodingImpl ?: new JsonDecode([
        JsonDecode::ASSOCIATIVE => TRUE,
    ]);
}

API Navigation

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