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

146
Views
Why JSON.parse fails with this array-like string

I tried to JSON parse this

  let string = `["\"test1, "\"test2"]`;
  let array = JSON.parse(string);
  console.log(array[0]);

It's fairly simple enough but I don't understand what's error message is supposed to tell

  Uncaught SyntaxError: Unexpected token t in JSON at position 3
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you are using template string to create a string. it doesnt need a escape character for double quotes ". type this:

let string = `["test1", "test2"]`;
let array = JSON.parse(string);
console.log(array[0])

you need a escape character for " only when you are using normal string. like this:

let string = "[\"test1\", \"test2\"]";
let array = JSON.parse(string);
console.log(array[0])

im not good at english.hope useful

about 4 years ago · Juan Pablo Isaza 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!