class Json in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json
Default serialization for JSON.
Hierarchy
- class \Drupal\Component\Serialization\Json implements SerializationInterface
Expanded class hierarchy of Json
File
- lib/
Drupal/ Component/ Serialization/ Json.php, line 15 - Contains \Drupal\Component\Serialization\Json.
Namespace
Drupal\Component\SerializationView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Json:: |
public static | function |
Decodes data from the serialization format. Overrides SerializationInterface:: |
|
Json:: |
public static | function |
Uses HTML-safe strings, with several characters escaped. Overrides SerializationInterface:: |
|
Json:: |
public static | function |
Gets the file extension for this serialization format. Overrides SerializationInterface:: |