Replace smart_str with php_json_buffer (not tested)