jsoncpp
jsoncpp copied to clipboard
In Windows 10 Education Edition 21H2 using json 1.9.3 to write json files, garbled characters
Describe the bug
In Windows 10 Education 21H2 using json 1.9.3 to write json files, the saved json files are garbled
To Reproduce
This bug only occurs on certain computers and works well on other computers. The system information of this computer is as follows
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):
- OS: Windows 10 Education 21H2 Operating system build:19044.1320