Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
41
core/lib/Drupal/Component/Serialization/Json.php
Normal file
41
core/lib/Drupal/Component/Serialization/Json.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Component\Serialization\Json.
|
||||
*/
|
||||
|
||||
namespace Drupal\Component\Serialization;
|
||||
|
||||
/**
|
||||
* Default serialization for JSON.
|
||||
*
|
||||
* @ingroup third_party
|
||||
*/
|
||||
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';
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue