$data = array('name' => 'John Doe', 'age' => 30, 'hobbies' => array('reading', 'hiking', 'coding')); $json = CJSON::encode($data); echo $json; // {"name":"John Doe","age":30,"hobbies":["reading","hiking","coding"]}
$json = '{"name":"John Doe","age":30,"hobbies":["reading","hiking","coding"]}'; $data = CJSON::decode($json); print_r($data); /* Array ( [name] => John Doe [age] => 30 [hobbies] => Array ( [0] => reading [1] => hiking [2] => coding ) ) */In this example, the `decode` method of the CJSON package is used to convert the JSON string `$json` into a PHP array. The resulting array is then printed to the browser using the `print_r` function. Based on these examples, it is likely that the CJSON package is part of the Yii framework, which is a popular PHP framework that provides a wide range of functionality for building web applications.