How to Remove Quotes from JSON Key in Javascript?
Nov 25, 2022 . Admin
Hello friends,
In this short tutorial, we will cover how to remove quotes from JSON key in javascript. This article will give you a simple example of how to remove quotes from the JSON key. I’m going to show you about removing quotes from JSON. Here you will learn to remove quotes from the JSON key in javascript.
To remove quotes from the JSON key you can use replace() method, we have to see how to remove quotes from JSON key with an example.
So, let's see bellow solution:
Example:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>How to Remove Quotes from JSON Key in Javascript?</title> </head> <body> <script type="text/javascript"> //create jsonEmp var jsonEmp='{"Table" : [{"userid" : "18","name" : "Virat","designation" : "Business Head","phone" : "9789234793","email" : "virat@gmail.com","role" : "Admin"}]}'; //remove quotes from keys jsonEmp=jsonEmp.replace(/"(\w+)"\s*:/g, '$1:'); //print removed quotes console.log(jsonEmp); </script> </body> </html>Check The Console For Output:
{Table: [{userid: "18",name: "Virat",designation: "Business Head",phone: "9789234793",email: "virat@gmail.com",role: "Admin"}]}
I hope it will help you...