You are here

class Json in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json

Default serialization for JSON.

Hierarchy

Expanded class hierarchy of Json

Related topics

51 files declare their use of Json
ActiveLinkResponseFilter.php in core/lib/Drupal/Core/EventSubscriber/ActiveLinkResponseFilter.php
Contains \Drupal\Core\EventSubscriber\ActiveLinkResponseFilter.
ActiveLinkResponseFilterTest.php in core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php
Contains \Drupal\Tests\Core\EventSubscriber\ActiveLinkResponseFilterTest.
AssertContentTrait.php in core/modules/simpletest/src/AssertContentTrait.php
Contains \Drupal\simpletest\AssertContentTrait.
AttachedAssetsTest.php in core/modules/system/src/Tests/Common/AttachedAssetsTest.php
Contains \Drupal\system\Tests\Common\AttachedAssetsTest.
BasicTest.php in core/modules/views/src/Tests/Wizard/BasicTest.php
Contains \Drupal\views\Tests\Wizard\BasicTest.

... See full list

1 string reference to 'Json'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses Json
serialization.json in core/core.services.yml
Drupal\Component\Serialization\Json

File

core/lib/Drupal/Component/Serialization/Json.php, line 15
Contains \Drupal\Component\Serialization\Json.

Namespace

Drupal\Component\Serialization
View source
class Json implements SerializationInterface {

  /**
   * {@inheritdoc}
   *
   * Uses HTML-safe strings, with several characters escaped.
   */
  public static function encode($variable) {

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

  /**
   * {@inheritdoc}
   */
  public static function decode($string) {
    return json_decode($string, TRUE);
  }

  /**
   * {@inheritdoc}
   */
  public static function getFileExtension() {
    return 'json';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Json::decode public static function Decodes data from the serialization format. Overrides SerializationInterface::decode
Json::encode public static function Uses HTML-safe strings, with several characters escaped. Overrides SerializationInterface::encode
Json::getFileExtension public static function Gets the file extension for this serialization format. Overrides SerializationInterface::getFileExtension