function drupal_json_output
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.
22 calls to drupal_json_output()
- announce_feed_test_set_feed_config in modules/
announcements_feed/ tests/ announce_feed_test.module - Helper function to set announcements feed URL.
- database_test_db_query_temporary in 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 modules/
simpletest/ tests/ database_test.module - Run a pager query and return the results.
- database_test_odd_pager_query in modules/
simpletest/ tests/ database_test.module - Run a pager query and return the results.
- database_test_tablesort in modules/
simpletest/ tests/ database_test.module - Run a tablesort query and return the results.
1 string reference to 'drupal_json_output'
- system_menu in modules/
system/ system.module - Implements hook_menu().
File
-
includes/
common.inc, line 5317
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.