$data = array( 'name' => 'John', 'age' => 30, 'city' => 'New York' ); $json = Zend_Json::prettyPrint(Zend_Json::encode($data)); echo $json;
$json = '{"name":"John","age":30,"city":"New York"}'; $data = Zend_Json::decode($json); echo Zend_Json::prettyPrint(Zend_Json::encode($data));This example demonstrates how to pretty-print JSON data that has already been encoded. The JSON string is first decoded using Zend_Json::decode, and the resulting associative array is then encoded again using Zend_Json::encode. The prettyPrint method is then used to generate a pretty-printed JSON output, which is printed to the screen. The above examples demonstrate the use of the Zend_Json package library.