Support return Unicode escapes

This commit is contained in:
2026-03-30 22:50:07 +11:00
parent 120b0e4f01
commit 0c24096c80
4 changed files with 10 additions and 9 deletions

View File

@@ -197,7 +197,7 @@ namespace ANSCENTER {
{"y", std::to_string(det.box.y)},
{"width", std::to_string(det.box.width)},
{"height", std::to_string(det.box.height)},
{"mask", ""}, // TODO: convert masks to comma separated string
{"mask", ""},
{"extra_info", det.extraInfo},
{"camera_id", det.cameraId},
{"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) {
// Add your error logging here if needed
@@ -839,7 +840,7 @@ namespace ANSCENTER {
for (const auto& part : res.parts) {
alprInfo[part.first] = part.second;
}
std::string extraInfoStr = alprInfo.dump();
std::string extraInfoStr = alprInfo.dump(-1, ' ', true);
// Use the same field layout as OCRDetectionToJsonString
jsonResults.push_back({
@@ -858,7 +859,7 @@ namespace ANSCENTER {
{"kps", ""}
});
}
return root.dump();
return root.dump(-1, ' ', true);
} catch (const std::exception&) {
return R"({"results":[],"error":"ALPR serialization failed"})";
}