function drupal_json_encode

Converts a PHP variable into its JavaScript equivalent.

We use HTML-safe strings, with several characters escaped.

See also

drupal_json_decode()

Related topics

8 calls to drupal_json_encode()

File

drupal/core/includes/common.inc, line 4697
Common functions that many Drupal modules will need to reference.

Code

function drupal_json_encode($var) {

  // Encode <, >, ', &, and " using the json_encode() options parameter.
  return json_encode($var, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
}