Detailed Description

JsonFormat implements the JSON request/response format.

All data will be serialized using the json_encode method except for Nodes. Nodes are serialized into an array before encoding (see JsonFormat::serializeValue) using the NodeSerializer class. On serialization the data will be outputted directly using the print command.

JsonFormat collects the response data from all executed controllers into one response array and returns it all at once at the end of script execution. This prevents from having multiple chunks of JSON from each controller response that can't be decoded by clients.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 33 of file JsonFormat.php.

+ Inheritance diagram for JsonFormat:

Public Member Functions

 __construct (NodeSerializer $serializer, Cache $dynamicCache)
 
 getMimeType ()
 
 isCached (Response $response)
 
 getCacheDate (Response $response)
 
- Public Member Functions inherited from AbstractFormat
 deserialize (Request $request)
 
 serialize (Response $response)
 
 getResponseHeaders (Response $response)
 

Public Attributes

const CACHE_SECTION = 'jsonformat'
 

Protected Member Functions

 getCacheSection (Response $response)
 
 afterSerialize (Response $response)
 
 isSerializedNode ($value)
 
 serializeNode ($value)
 
 deserializeNode ($value)
 
- Protected Member Functions inherited from HierarchicalFormat
 deserializeValues (Request $request)
 
 serializeValues (Response $response)
 
 isSerializedNode ($value)
 
 isDeserializedNode ($value)
 
 serializeNode ($value)
 
 deserializeNode ($value)
 
- Protected Member Functions inherited from AbstractFormat
 beforeDeserialize (Request $request)
 
 deserializeValues (Request $request)
 
 afterDeserialize (Request $request)
 
 beforeSerialize (Response $response)
 
 serializeValues (Response $response)
 
 afterSerialize (Response $response)
 
 getNode (ObjectId $oid)
 
 filterValue ($value, AttributeDescription $attribute)
 

Protected Attributes

 $cache = null
 
 $serializer = null
 

Constructor & Destructor Documentation

__construct ( NodeSerializer  $serializer,
Cache  $dynamicCache 
)

Constructor.

Parameters
$serializerNodeSerializer instance
$dynamicCacheCache instance

Definition at line 47 of file JsonFormat.php.

Member Function Documentation

getCacheSection ( Response  $response)
protected

Get the cache section for a response.

Parameters
Response$response
Returns
String

Definition at line 60 of file JsonFormat.php.

getMimeType ( )
See also
Format::getMimeType()

Implements Format.

Definition at line 68 of file JsonFormat.php.

isCached ( Response  $response)
See also
Format::isCached()

Implements Format.

Definition at line 75 of file JsonFormat.php.

getCacheDate ( Response  $response)
See also
Format::isCached()

Implements Format.

Definition at line 83 of file JsonFormat.php.

afterSerialize ( Response  $response)
protected
See also
HierarchicalFormat::afterSerialize()

Definition at line 91 of file JsonFormat.php.

isSerializedNode (   $value)
protected
See also
HierarchicalFormat::isSerializedNode()

Definition at line 122 of file JsonFormat.php.

serializeNode (   $value)
protected
See also
HierarchicalFormat::serializeNode()

Definition at line 129 of file JsonFormat.php.

deserializeNode (   $value)
protected
See also
HierarchicalFormat::deserializeNode()

Definition at line 137 of file JsonFormat.php.

Member Data Documentation

const CACHE_SECTION = 'jsonformat'

Definition at line 35 of file JsonFormat.php.

$cache = null
protected

Definition at line 39 of file JsonFormat.php.

$serializer = null
protected

Definition at line 40 of file JsonFormat.php.