manual buffering during json serialization