- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Strip quotes with JavaScript to convert into JSON object?
For this, you can use replace() along with parse(). Following is the code −
Example
var studentDetails = `"{""name"": ""John"",""subjectName"": ""Introduction To JavaScript""}"`; console.log("The actual object="); console.log(studentDetails); var removeFirstAndLast = studentDetails.substring(1,studentDetails.length-1) var removeDoubleQuotes = removeFirstAndLast.replace(/""/gi, `"`) console.log(removeDoubleQuotes) var output = JSON.parse(removeDoubleQuotes); console.log(output);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo103.js.
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo103.js The actual object= "{""name"": ""John"",""subjectName"": ""Introduction To JavaScript""}" {"name": "John","subjectName": "Introduction To JavaScript"} { name: 'John', subjectName: 'Introduction To JavaScript' }
- Related Articles
- How to convert a JSON string into a JavaScript object?
- How to convert JSON text to JavaScript JSON object?
- Convert JSON array into normal json in JavaScript
- How to convert a date object's content into json in JavaScript?
- How to convert JSON data into a Python object?
- How to deserialize a JSON into Javascript object?
- Convert JSON to another JSON format with recursion JavaScript
- How to transform JSON text into a JavaScript object?
- How to turn a JSON object into a JavaScript array in JavaScript ?
- Converting two arrays into a JSON object in JavaScript
- Convert JS array into an object - JavaScript
- How to convert square bracket object keys into nested object in JavaScript?
- Python - Ways to convert string to json object
- How to convert JSON string into Lua table?
- How to convert an object into an array in JavaScript?

Advertisements