Update cJSONw.cpp

This commit is contained in:
blueloveTH 2023-10-15 16:06:49 +08:00
parent 7922513255
commit acdab59d94

View File

@ -115,8 +115,12 @@ void add_module_cjson(VM* vm){
const Str& string = CAST(Str&, args[0]); const Str& string = CAST(Str&, args[0]);
cJSON *json = cJSON_ParseWithLength(string.data, string.size); cJSON *json = cJSON_ParseWithLength(string.data, string.size);
if(json == NULL){ if(json == NULL){
const char* err = cJSON_GetErrorPtr(); const char* start = cJSON_GetErrorPtr();
vm->IOError(fmt("cjson: ", err)); const char* end = start;
while(*end != '\0' && *end != '\n'){
end++;
}
vm->IOError(fmt("cjson: ", std::string_view(start, end-start)));
UNREACHABLE(); UNREACHABLE();
} }
PyObject* output = convert_cjson_to_python_object(json, vm); PyObject* output = convert_cjson_to_python_object(json, vm);