Streaming JSON serializer.
Usage:
try {
$s = new JsonStream(STDOUT);
$s->startObject();
$s->writeProperty('name', 'John');
$s->writeProperty('age', 32);
$s->writeKey('pets')
->startArray()
->write('Garfield')
->write('Ido')
->end();
$s->writeProperty('data', array('list' => array(), 'of' => 'precompiled stuff'));
$s->close();
}
catch (JsonStreamException $e) {
error_log(var_export($e->getJsonState(), TRUE));
throw $e;
}