You are here

class JsonEncoder in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/serializer/Encoder/JsonEncoder.php \Symfony\Component\Serializer\Encoder\JsonEncoder
  2. 8 core/modules/hal/src/Encoder/JsonEncoder.php \Drupal\hal\Encoder\JsonEncoder
  3. 8 core/modules/serialization/src/Encoder/JsonEncoder.php \Drupal\serialization\Encoder\JsonEncoder
Same name and namespace in other branches
  1. 8.0 core/modules/hal/src/Encoder/JsonEncoder.php \Drupal\hal\Encoder\JsonEncoder

Encodes HAL data in JSON.

Simply respond to hal_json format requests using the JSON encoder.

Hierarchy

Expanded class hierarchy of JsonEncoder

2 files declare their use of JsonEncoder
FileNormalizeTest.php in core/modules/hal/src/Tests/FileNormalizeTest.php
Contains \Drupal\hal\Tests\FileNormalizeTest.
NormalizerTestBase.php in core/modules/hal/src/Tests/NormalizerTestBase.php
Contains \Drupal\hal\Tests\NormalizerTestBase.
1 string reference to 'JsonEncoder'
hal.services.yml in core/modules/hal/hal.services.yml
core/modules/hal/hal.services.yml
1 service uses JsonEncoder
serializer.encoder.hal in core/modules/hal/hal.services.yml
Drupal\hal\Encoder\JsonEncoder

File

core/modules/hal/src/Encoder/JsonEncoder.php, line 17
Contains \Drupal\hal\Encoder\JsonEncoder.

Namespace

Drupal\hal\Encoder
View source
class JsonEncoder extends SymfonyJsonEncoder {

  /**
   * The formats that this Encoder supports.
   *
   * @var string
   */
  protected $format = 'hal_json';

  /**
   * {@inheritdoc}
   */
  public function supportsEncoding($format) {
    return $format == $this->format;
  }

  /**
   * {@inheritdoc}
   */
  public function supportsDecoding($format) {
    return $format == $this->format;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
JsonEncoder::$decodingImpl protected property
JsonEncoder::$encodingImpl protected property
JsonEncoder::$format protected property The formats that this Encoder supports.
JsonEncoder::decode public function Decodes a string into PHP data. Overrides DecoderInterface::decode
JsonEncoder::encode public function Encodes data into the given format. Overrides EncoderInterface::encode
JsonEncoder::FORMAT constant
JsonEncoder::getLastDecodingError Deprecated public function Returns the last decoding error (if any).
JsonEncoder::getLastEncodingError Deprecated public function Returns the last encoding error (if any).
JsonEncoder::getLastErrorMessage public static function Resolves json_last_error message.
JsonEncoder::supportsDecoding public function Checks whether the deserializer can decode from given format. Overrides JsonEncoder::supportsDecoding
JsonEncoder::supportsEncoding public function Checks whether the serializer can encode to given format. Overrides JsonEncoder::supportsEncoding
JsonEncoder::__construct public function