fixed infinite loop in safe_json_string