O'Reilly logo
  • Angela Saval thinks this is interesting:

Using JSON, you can arbitrarily nest JavaScript objects. In addition, you can use arrays (with the bracket notation) and most other data types available in JavaScript.

Drupal provides a (PHP) function named drupal_to_js() that converts a PHP array to JSON. The function drupal_json() automatically adds the right content type to the HTTP header and outputs the passed array as JSON. Use this function when you want to create a response from within Drupal.


Cover of Front End Drupal: Designing, Theming, Scripting


Using AJAX and JSON