function drupal_json_output

7.x common.inc drupal_json_output($var = NULL)

Returns data in JSON format.

This function should be used for JavaScript callback functions returning data in JSON format. It sets the header for JavaScript output.

Parameters

$var: (optional) If set, the variable will be converted to JSON and output.

20 calls to drupal_json_output()
database_test_db_query_temporary in drupal-7.x/modules/simpletest/tests/database_test.module
Run a db_query_temporary and output the table name and its number of rows.
database_test_even_pager_query in drupal-7.x/modules/simpletest/tests/database_test.module
Run a pager query and return the results.
database_test_odd_pager_query in drupal-7.x/modules/simpletest/tests/database_test.module
Run a pager query and return the results.
database_test_tablesort in drupal-7.x/modules/simpletest/tests/database_test.module
Run a tablesort query and return the results.
database_test_tablesort_first in drupal-7.x/modules/simpletest/tests/database_test.module
Run a tablesort query with a second order_by after and return the results.

... See full list

1 string reference to 'drupal_json_output'
system_menu in drupal-7.x/modules/system/system.module
Implements hook_menu().

File

drupal-7.x/includes/common.inc, line 5041
Common functions that many Drupal modules will need to reference.

Code

function drupal_json_output($var = NULL) {
  // We are returning JSON, so tell the browser.
  drupal_add_http_header('Content-Type', 'application/json');

  if (isset($var)) {
    echo drupal_json_encode($var);
  }
}