mardi 28 juin 2016

MongoDB C++ Driver 3.0 get document in string and avoid json

I am trying to get double type data from the database as the documentation says:

auto cursor = db["collection"].find({}, opts);
for (auto&& doc : cursor) {
    std::cout << bsoncxx::to_json(doc) << std::endl;
}

But I want to avoid converting doc into json because I lost decimal precision. For example:

In database shows this:

"lng" : -58.4682568037741

But after converting to json, I receive this:

"lng" : -58.4682

Is there any way to convert it directly to string, for example?

Aucun commentaire:

Enregistrer un commentaire