You are here

public static function Json::encode in Plug 7

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);
}