You are here

public static function Json::encode in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()
  2. 9 core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()

Uses HTML-safe strings, with several characters escaped.

61 calls to Json::encode()
ActiveLinkResponseFilter::setLinkActiveClass in core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
Sets the "is-active" class on relevant links.
ActiveLinkResponseFilterTest::providerTestSetLinkActiveClass in core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
Provides test data for testSetLinkActiveClass().
BigPipeTest::testBigPipe in core/modules/big_pipe/tests/src/Functional/BigPipeTest.php
Tests BigPipe-delivered HTML responses when JavaScript is enabled.
BlockLibraryController::listBlocks in core/modules/block/src/Controller/BlockLibraryController.php
Shows a list of blocks that can be added to a theme's layout.
BlockListBuilder::buildBlocksForm in core/modules/block/src/BlockListBuilder.php
Builds the main "Blocks" portion of the form.

... See full list

File

core/lib/Drupal/Component/Serialization/Json.php, line 17

Class

Json
Default serialization for JSON.

Namespace

Drupal\Component\Serialization

Code

public static function encode($variable) {

  // Encode <, >, ', &, and ".
  return json_encode($variable, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
}