You are here

public static function Json::encode in Service Container 7

Same name and namespace in other branches
  1. 7.2 lib/Drupal/Component/Serialization/Json.php \Drupal\Component\Serialization\Json::encode()

Uses HTML-safe strings, with several characters escaped.

Overrides SerializationInterface::encode

File

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

Class

Json
Default serialization for JSON.

Namespace

Drupal\Component\Serialization

Code

public static function encode($variable) {

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