我现在想给一个documents里边某一个字段设定二进制数据并且插入数据库。
我说的不是整个二进制文件。
想用一下方式传入数据
DBClientConnection oDB;
const std::string test =
"{insert: \"test1\", documents: [{\"_id\" : 6,\"name\":\"vector6\",\"value\":0x00}]}";
bool runret = oDB.runCommand("wjhtest", mongo::fromjson(test), p2, 0);
结果出错了。我想问二进制的数据怎么插入呢。求例子
高洛峰2017-04-17 14:30:46
The 0x00
you have here is actually a string, and what you want to insert is the value of 0x00
, which is 0
.
So you need to convert your 0x00
into a string, i.e. "value":0