function drupal_json_encode


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 drupal_json_encode($var)
cle7 drupal_json_encode($var)
elmsmedia7 drupal_json_encode($var)
icor7 drupal_json_encode($var)
meedjum_blog7 drupal_json_encode($var)
mooc7 drupal_json_encode($var)

Converts a PHP variable into its JavaScript equivalent.

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

See also



Related topics

24 calls to drupal_json_encode()
advagg_pre_render_scripts in sites/all/modules/ulmus/advagg/advagg.module
Callback for pre_render to add elements needed for JavaScript to be rendered.
ajax_render in includes/
Renders a commands array into JSON.
cis_helper_add_offering_page in profiles/cis/modules/custom/cis_helper/
Callback for setting up an offering for existing courses.
cis_helper_quick_setup_access_id_page in profiles/cis/modules/custom/cis_helper/
Callback for setting up course by knowing access string.
cis_helper_quick_setup_access_id_page_submit in profiles/cis/modules/custom/cis_helper/
Submit handler for cis_helper_offering_planning_page.

... See full list


includes/, line 5003
Common functions that many Drupal modules will need to reference.


function drupal_json_encode($var) {
  // The PHP version cannot change within a request.
  static $php530;

  if (!isset($php530)) {
    $php530 = version_compare(PHP_VERSION, '5.3.0', '>=');

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

  // json_encode() escapes <, >, ', &, and " using its options parameter, but
  // does not support this parameter prior to PHP 5.3.0.  Use a helper instead.
  include_once DRUPAL_ROOT . '/includes/';
  return drupal_json_encode_helper($var);