在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 祖国七十华诞简短祝福语
12 老师送的祝福语简短
13 生日祝福语大全女生简短
14 祝女性生日祝福语简短
15 牛年女神节祝福语简短
16 情人表白祝福语简短大气
17 老公开业祝福语简短
18 官宣新年祝福语简短