-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
I'm using the mongocxx (v3) driver in my project to store the app settings in the mongodb. While working in windows everything seems to work well. But now that i'm testing in linux i have noticed some problems that i cannot understand why are happening.
i have the following function to retrieve the app settings:
QJsonObject MongoDBManager::getProjectsSettings(QString appid,QString projectsname) { try { if(m_selectedDB.has_collection(projectsname.toStdString())==false){ LOG_ERROR()<<"collection '"+projectsname+"' do not exist"; return QJsonObject(); } mongocxx::collection selectedCollection = m_selectedDB[projectsname.toStdString()]; auto cursor =selectedCollection.find(document{} << "appid" << appid.toStdString() << finalize); // auto cursor = m_selectedCollection.find(document{} << "_id" << appid.toStdString() << finalize); for (auto &&doc : cursor) { bsoncxx::builder::stream::document s; s << "x" << 1.0; std::cout<<"testing:" << bsoncxx::to_json(s) << std::endl; std::cout<<"doc:"<< bsoncxx::to_json(doc)<<std::endl; }
the output:
....
testing:{ "x" : 1.0 }
doc:{ "_id" :
, "appid" : "5ea8a4192483621670ffeb2b", "value" : 1,1000000000000000888 }
[![In the database i have:][1]][1]
[1]: https://i.stack.imgur.com/6eE8H.png
::tojson returns a string with a comma instead of a dot in the decimal separator witch obviously is an invalid JSON document.
... "value" : 1,1000000000000000888 }
the workaround is to change my local to en_US, but shouldn't the returned string be independent of the locale?
- is duplicated by
-
CDRIVER-3812 bson_as_json outputs illegal JSON for some locales
- Backlog