在MongoDB中插入记录时转义引号?
双引号具有unicode,其值为\u0022。首先让我们创建一个包含文档的集合-
> db.escapingQuotesDemo.insert({ "StudentFullName": "John \u0022 Smith" });
WriteResult({ "nInserted" : 1 })
> db.escapingQuotesDemo.insert({ "StudentFullName": "David \u0022 Miller" });
WriteResult({ "nInserted" : 1 })
> db.escapingQuotesDemo.insert({ "StudentFullName": "John \u0022 Doe" });
WriteResult({ "nInserted" : 1 })
> db.escapingQuotesDemo.insert({ "StudentFullName": "Carol \u0022 Taylor" });
WriteResult({ "nInserted" : 1 })以下是在find()方法的帮助下显示集合中所有文档的查询-
> db.escapingQuotesDemo.find().pretty();
这将产生以下输出-
{
"_id" : ObjectId("5ccf42e2dceb9a92e6aa195b"),
"StudentFullName" : "John \" Smith"
}
{
"_id" : ObjectId("5ccf42f0dceb9a92e6aa195c"),
"StudentFullName" : "David \" Miller"
}
{
"_id" : ObjectId("5ccf42f9dceb9a92e6aa195d"),
"StudentFullName" : "John \" Doe"
}
{
"_id" : ObjectId("5ccf4303dceb9a92e6aa195e"),
"StudentFullName" : "Carol \" Taylor"
}热门推荐
10 牛年新年祝福语大全简短
11 出院祝福语简短8字
12 贺卡祝福语宝宝男孩简短
13 项目总生日祝福语简短
14 给新年祝福语简短独特
15 对上司的简短祝福语
16 哥哥新婚祝福语创意简短
17 简短古文生日祝福语
18 宝宝新年祝福语大全简短