function Json::encode
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()
- 10 core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()
- 11.x core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()
Uses HTML-safe strings, with several characters escaped.
Overrides SerializationInterface::encode
64 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.
File
-
core/
lib/ Drupal/ Component/ Serialization/ Json.php, line 17
Class
- Json
- Default serialization for JSON.
Namespace
Drupal\Component\SerializationCode
public static function encode($variable) {
// Encode <, >, ', &, and ".
return json_encode($variable, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.