quercus json

JSON (JavaScript Object Notation) is a popular text data
exchange format with built-in support from Quercus since Resin 3.0.20.
One of the common uses of JSON in a PHP environment is for the server
to send JSON data to the user's browser. Because the JSON language is
a subset of JavaScript, JSON-encoded text can be readily parsed on the
user's browser using JavaScript's eval() function.

Files in this tutorial

Using JSON in Quercus

Quercus has built-in JSON support and JSON functionality is enabled the moment Quercus is started: no additional downloads are required. Quercus sports two PHP functions for working with JSON: json_encode and json_decode.

AJAX Example

JSON data is more commonly sent to
the browser via AJAX requests. Suppose there are two files defined
below. The PHP script in json.php encodes an array into JSON.
When the user's browser is directed to json.html, an AJAX
request receives JSON data from json.php. Then the browser
calls eval() on the JSON data to recover a JavaScript object.