Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
How can i remove the 3rd and last double quote from a nested string using JS (if not possible, how can i do it using Regex)

I want "data" to still have double quotes but i dont want double quotes wrapping data's value object. Note, "description" may have have a different number of characters each time. Finally, this will be used for 100+ items

I have this:

{"data": "{"id": 1, "name": "test", "description": "description with variable number of characters"}"}

I want this:

{"data": {"id": 1, "name": "test", "description": "description with variable number of characters"}}

remove the (") wrapping the id, name, description object

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Use JSON.parse for parsing JSON data.

const data = `{"data": "{\\"id\\": 1, \\"name\\": \\"test\\", \\"description\\": \\"description with variable number of characters\\"}"}`;

let parsed = JSON.parse(data);
parsed.data = JSON.parse(parsed.data);

const result = JSON.stringify(parsed, null, 2);
console.log(result);

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!