I'm having difficulties converting a bson document to a json string using bsoncxx. The bsoncxx::to_json function return an "invalid"/corrupted std::string object.. I can't read the character in it, and it crash when the std::string is destructed..
I've rebuild everything: mongoc,libbson, mongocxx, etc...
Here's a sample code :
bsoncxx::builder::basic::document doc{};
doc.append(bsoncxx::builder::basic::kvp("test", 1));
auto string = bsoncxx::to_json(doc);
I can't extract the data from the string, because std::end(string) crash with a "read access violation" when I try to copy the content with std::copy...
I'm using mongodb everywhere in the program and accessing bson document and everything works fine. I tried to call bsoncxx::to_json on an already existing bson document returned by a mongodb query but it had the same behavior...
I'm trying to stream a byte array ( plus, some information like how to decode the byte array ) using boost tcp sockets to a nodejs program so I thought I could simply create a document with a "binary field", convert it to json and stream it over the tcp socket...
Anyone knows how I could do that, either by fixing the bsoncxx::to_json, or by using something else ?
thanks
Aucun commentaire:
Enregistrer un commentaire