How to Remove Square Brackets from JSON Object in Javascript?
Nov 17, 2022 . Admin
Hello friends,
In this article, we will talk about how to remove square brackets in javascript. it's a simple example of removing square brackets from JSON object in javascript. This article goes into detail on removing square brackets of JSON.
To remove the square brackets from the JSON object you can use replace(). We have to see how to remove square brackets from JSON object with an example.
So, let's see bellow solution:
Example:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>How to Remove Square Brackets from JSON Object in Javascript?</title> </head> <body> <script type="text/javascript"> //create jsonPlayer var jsonPlayer = "\[David Warner\]"; //print remove square brackets from an object console.log(jsonPlayer.replace(/[\[\]']+/g, '')); </script> </body> </html>Check The Console For Output:
David Warner
I hope it will help you...