open-source-parsers / jsoncpp

A C++ library for interacting with JSON.
Other
8.06k stars 2.63k forks source link

In Windows 10 Education Edition 21H2 using json 1.9.3 to write json files, garbled characters #1495

Open booksuper opened 1 year ago

booksuper commented 1 year ago

Describe the bug In Windows 10 Education 21H2 using json 1.9.3 to write json files, the saved json files are garbled image

To Reproduce This bug only occurs on certain computers and works well on other computers. The system information of this computer is as follows 749f4161-3f8b-4e88-ba77-c26d6c8db4c0 The code to write JSON is as follows `std::cout << "save json开始运行" << std::endl; Json::Value jobject;

jobject["roiType"] = (int)roiType;
jobject["isOpenDetROI"] = isOpenDetROI;
jobject["rectDetROIx"] = rectDetROI.x;
jobject["rectDetROIy"] = rectDetROI.y;
jobject["rectDetROIwidth"] = rectDetROI.width;
jobject["rectDetROIheight"] = rectDetROI.height;

std::cout << "roiType" << roiType<< std::endl;
//Point2f[] pts = new Point2f[RoiDetPts.Count()];

Json::Value RoiDetPtsArr;
for (int n = 0; n < RoiDetPts.size(); ++n)
{
    Json::Value pt_arr;
    pt_arr.append(RoiDetPts[n].x);
    pt_arr.append(RoiDetPts[n].y);
    RoiDetPtsArr.append(pt_arr);
}
jobject["RoiDetPts"] = RoiDetPtsArr;
jobject["magicSize"] = magicSize;
jobject["needRemoveSmallContour"] = needRemoveSmallContour;
jobject["smallContourSize"] = smallContourSize;
jobject["needInnerContour"] = needInnerContour;
jobject["colorType"] = needInnerContour;

jobject["preProcessMethod"] = (int)preProcessMethod;
jobject["needBlur"] = needBlur;
jobject["BlurMethod"] = (int)BlurMethod;
jobject["BlurSize"] = BlurSize;
jobject["needMorh"] = needMorh;
jobject["morhType"] = morhType;
jobject["morhSize"] = morhSize;

jobject["isManualValue"] = isManualValue;
jobject["manualValue"] = manualValue;
jobject["thresholdMethod"] = (int)thresholdMethod;
Json::StyledWriter sw;

ofstream os;
os.open(FilenName, std::ios::out | std::ios::app);
if (!os.is_open())
    cout << "error:can not find or create the file which named \" *.json\"." << endl;
os << sw.write(jobject);
os.close();`

Expected behavior I hope that there will be no garbled characters when saving JSON files. Even if it is saved as garbled, there can be a status prompt

Desktop (please complete the following information):

resFiles.zip