Support return Unicode escapes
This commit is contained in:
@@ -2379,7 +2379,7 @@ namespace ANSCENTER {
|
|||||||
END_TIMER(json_build, "JSON Build Time");
|
END_TIMER(json_build, "JSON Build Time");
|
||||||
|
|
||||||
START_TIMER(json_serialize);
|
START_TIMER(json_serialize);
|
||||||
std::string result = root.dump();
|
std::string result = root.dump(-1, ' ', true);
|
||||||
END_TIMER(json_serialize, "JSON Serialize Time");
|
END_TIMER(json_serialize, "JSON Serialize Time");
|
||||||
|
|
||||||
END_TIMER(json_total, "JSON Conversion Total Time");
|
END_TIMER(json_total, "JSON Conversion Total Time");
|
||||||
@@ -2416,7 +2416,7 @@ namespace ANSCENTER {
|
|||||||
|
|
||||||
root["results"] = detectedObjects;
|
root["results"] = detectedObjects;
|
||||||
|
|
||||||
return root.dump(); // or root.dump(4) for pretty-printed JSON with 4-space indent
|
return root.dump(-1, ' ', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validation helper methods
|
// Validation helper methods
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ namespace ANSCENTER {
|
|||||||
{"kps", KeypointsToString(det.kps)}
|
{"kps", KeypointsToString(det.kps)}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return root.dump();
|
return root.dump(-1, ' ', true);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
this->_logger.LogFatal("ANSALPR::VectorDetectionToJsonString", e.what(), __FILE__, __LINE__);
|
this->_logger.LogFatal("ANSALPR::VectorDetectionToJsonString", e.what(), __FILE__, __LINE__);
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ namespace ANSCENTER {
|
|||||||
{"y", std::to_string(det.box.y)},
|
{"y", std::to_string(det.box.y)},
|
||||||
{"width", std::to_string(det.box.width)},
|
{"width", std::to_string(det.box.width)},
|
||||||
{"height", std::to_string(det.box.height)},
|
{"height", std::to_string(det.box.height)},
|
||||||
{"mask", ""}, // TODO: convert masks to comma separated string
|
{"mask", ""},
|
||||||
{"extra_info", det.extraInfo},
|
{"extra_info", det.extraInfo},
|
||||||
{"camera_id", det.cameraId},
|
{"camera_id", det.cameraId},
|
||||||
{"polygon", PolygonToString(det.polygon)},
|
{"polygon", PolygonToString(det.polygon)},
|
||||||
@@ -205,7 +205,8 @@ namespace ANSCENTER {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return root.dump();
|
// ensure_ascii=true escapes non-ASCII chars as \uXXXX for LabVIEW compatibility
|
||||||
|
return root.dump(-1, ' ', true);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
// Add your error logging here if needed
|
// Add your error logging here if needed
|
||||||
@@ -839,7 +840,7 @@ namespace ANSCENTER {
|
|||||||
for (const auto& part : res.parts) {
|
for (const auto& part : res.parts) {
|
||||||
alprInfo[part.first] = part.second;
|
alprInfo[part.first] = part.second;
|
||||||
}
|
}
|
||||||
std::string extraInfoStr = alprInfo.dump();
|
std::string extraInfoStr = alprInfo.dump(-1, ' ', true);
|
||||||
|
|
||||||
// Use the same field layout as OCRDetectionToJsonString
|
// Use the same field layout as OCRDetectionToJsonString
|
||||||
jsonResults.push_back({
|
jsonResults.push_back({
|
||||||
@@ -858,7 +859,7 @@ namespace ANSCENTER {
|
|||||||
{"kps", ""}
|
{"kps", ""}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return root.dump();
|
return root.dump(-1, ' ', true);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
return R"({"results":[],"error":"ALPR serialization failed"})";
|
return R"({"results":[],"error":"ALPR serialization failed"})";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1104,10 +1104,10 @@ namespace ANSCENTER {
|
|||||||
{"kps", KeypointsToString(det.kps)}
|
{"kps", KeypointsToString(det.kps)}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return root.dump();
|
// ensure_ascii=true escapes non-ASCII chars as \uXXXX for LabVIEW compatibility
|
||||||
|
return root.dump(-1, ' ', true);
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
// Add your error logging here if needed
|
|
||||||
return R"({"results":[],"error":"Serialization failed"})";
|
return R"({"results":[],"error":"Serialization failed"})";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user