
- MongoDB Tutorial
- MongoDB - Home
- MongoDB - Overview
- MongoDB - Advantages
- MongoDB - Environment
- MongoDB - Data Modeling
- MongoDB - Create Database
- MongoDB - Drop Database
- MongoDB - Create Collection
- MongoDB - Drop Collection
- MongoDB - Data Types
- MongoDB - Insert Document
- MongoDB - Query Document
- MongoDB - Update Document
- MongoDB - Delete Document
- MongoDB - Projection
- MongoDB - Limiting Records
- MongoDB - Sorting Records
- MongoDB - Indexing
- MongoDB - Aggregation
- MongoDB - Replication
- MongoDB - Sharding
- MongoDB - Create Backup
- MongoDB - Deployment
- MongoDB - Java
- MongoDB - PHP
- Advanced MongoDB
- MongoDB - Relationships
- MongoDB - Database References
- MongoDB - Covered Queries
- MongoDB - Analyzing Queries
- MongoDB - Atomic Operations
- MongoDB - Advanced Indexing
- MongoDB - Indexing Limitations
- MongoDB - ObjectId
- MongoDB - Map Reduce
- MongoDB - Text Search
- MongoDB - Regular Expression
- Working with Rockmongo
- MongoDB - GridFS
- MongoDB - Capped Collections
- Auto-Increment Sequence
- MongoDB Useful Resources
- MongoDB - Questions and Answers
- MongoDB - Quick Guide
- MongoDB - Useful Resources
- MongoDB - Discussion
Escaping quotes while inserting records in MongoDB?
The double quotes have unicode which has the value \u0022. Let us first create a collection with documents −
> 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 })
Following is the query to display all documents from a collection with the help of find() method −
> db.escapingQuotesDemo.find().pretty();
This will produce the following output −
{ "_id" : ObjectId("5ccf42e2dceb9a92e6aa195b"), "StudentFullName" : "John \" Smith" } { "_id" : ObjectId("5ccf42f0dceb9a92e6aa195c"), "StudentFullName" : "David \" Miller" } { "_id" : ObjectId("5ccf42f9dceb9a92e6aa195d"), "StudentFullName" : "John \" Doe" } { "_id" : ObjectId("5ccf4303dceb9a92e6aa195e"), "StudentFullName" : "Carol \" Taylor" }
- Related Articles
- Format date while inserting records in MySQL
- Display an error while inserting duplicate records in a MySQL table
- Escaping/encoding single quotes in JSON encoded HTML5 data attributes
- Can we use INTERVAL keyword while inserting date records in a MySQL table?
- Avoiding quotes while printing strings in Python
- Inserting Records into Table using Node
- Find records with double quotes in a MySQL column?
- How to insert records with double quotes in MySQL?
- Inserting the current datetime in MongoDB?
- Inserting Date() in MongoDB through Mongo shell?
- Inserting records into a MySQL table using PreparedStatement in Java?
- Escaping Characters in Perl
- Find duplicate records in MongoDB?
- How to convert positive value to negative while inserting in MySQL?
- Can we skip a column name while inserting values in MySQL?

Advertisements