From f32394817f1862f0b3ce888b5c3885025f85a5a0 Mon Sep 17 00:00:00 2001 From: Mahbub Alam Date: Sat, 14 Oct 2023 13:15:42 -0400 Subject: [PATCH] Fix tests --- 3rd/cjson/src/cJSONw.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/3rd/cjson/src/cJSONw.cpp b/3rd/cjson/src/cJSONw.cpp index 59391c0b..38b352ce 100644 --- a/3rd/cjson/src/cJSONw.cpp +++ b/3rd/cjson/src/cJSONw.cpp @@ -62,7 +62,8 @@ static std::string convert_python_object_to_string(PyObject* obj, VM* vm){ } } else if (is_type(obj, vm->tp_str)){ - return std::string("\"") + CAST(Str&, obj).c_str() + std::string("\""); + std::string str = CAST(Str&, obj).replace("\n", "\\n").replace("\"", "\\\"").c_str(); + return std::string("\"") + str + std::string("\""); } else if (is_type(obj, vm->tp_dict)){ return covert_dict_to_string(CAST(Dict&, obj), vm);