Uncaught SyntaxError: Unexpected token c in JSON at position 13

SAEO TWL

I have a string(var) that I parse as JSON in javascript. But as soon as I do that I get an error stating

Uncaught SyntaxError: Unexpected token c in JSON at position 13

var DL_response = {"result":"{"cov_details":[{"issue_date":"UNIT 
 OFFICE,NEYVELI","cov":"MCWG"}],"dl_number":"TN39Y20100000784","address":"PERIYA COLONY  KO PAVAZHANGUDI  
 VIRUDHACHALAM TK","issue_date":"24-03-2020","dob":"21-03-1971","name":"VICNESWARAN 
 S","blood_group":"","validity":{"transport":"","non-transport":"24-03-2010 to 23-03- 
 2030"},"father_husband":"SELVARAJ"}","status-code":"101","request_id":"a9642ae9-2f10-4e9a-9f7e- 
 c3ee1a9a2dbe"}
var Driving_License = JSON.parse(DL_response);

What might be causing this error? Is it because of any special characters?

Iftieaq

First of all, your JSON is invalid. And second of all, it's not a JSON string but a JavaScript Object itself. There is no need to parse it again. If the object was valid, you could access it directly without further parsing.

Here is the data I've fixed.

var DL_response = {
   "result":{
      "cov_details":[
         {
            "issue_date":"UNIT OFFICE,NEYVELI",
            "cov":"MCWG"
         }
      ],
      "dl_number":"TN39Y20100000784",
      "address":"PERIYA COLONY KO PAVAZHANGUDI  VIRUDHACHALAM TK",
      "issue_date":"24-03-2020",
      "dob":"21-03-1971",
      "name":"VICNESWARANS",
      "blood_group":"",
      "validity":{
         "transport":"",
         "non-transport":"24-03-2010 to 23-03-2030"
      },
      "father_husband":"SELVARAJ",
      "status-code":"101",
      "request_id":"a9642ae9-2f10-4e9a-9f7e-c3ee1a9a2dbe"
   }
}

console.log(DL_response.result.dob)
// output: 21-03-1971

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Uncaught SyntaxError: Unexpected token , in JSON at position 10

Uncaught SyntaxError: Unexpected token a in JSON at position 2

Uncaught SyntaxError: Unexpected token p in JSON at position 36

Selectize Uncaught SyntaxError: Unexpected token # in JSON at position 0

Uncaught SyntaxError: Unexpected token u in JSON at position 0

React Js: Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

how to fix Uncaught SyntaxError: Unexpected token o in JSON at position 1

Facing an Uncaught SyntaxError: Unexpected token o in JSON at position 1

Uncaught SyntaxError: Unexpected token < in JSON at position 0 from Codeigniter response

Uncaught SyntaxError: Unexpected token o in JSON at position 1 error

how to fix "Uncaught SyntaxError: Unexpected token _ in JSON at position . . . "

Uncaught Promise Rejection SyntaxError: Unexpected token u in JSON at position 0

Uncaught (in promise) SyntaxError: Unexpected token r in JSON at position 0

SyntaxError: Unexpected token \ in JSON at position

SyntaxError: Unexpected token } in JSON at position

JSON object issue: Uncaught SyntaxError: Unexpected token

JSON Parse: Uncaught SyntaxError: Unexpected token e

"Uncaught SyntaxError: Unexpected token H in JSON"

Uncaught SyntaxError: Unexpected token with JSON.parse

Uncaught SyntaxError: Unexpected token - JSON character encoding

javascript json uncaught syntaxerror unexpected token illegal

"Uncaught SyntaxError: Unexpected token" with JSON parse in backbone

Uncaught SyntaxError: Unexpected token U in JSON at position 0 at JSON.parse (<anonymous>) at Response.Body.json

Nextjs 13- Uncaught (in promise) SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Uncaught SyntaxError: Unexpected token T in JSON at position 0 at JSON.parse (Asp.net MVC)

Uncaught SyntaxError: Unexpected token a in JSON at position 0 at JSON.parse (<anonymous>)

Uncaught SyntaxError: Unexpected token < in JSON at position 0 : at JSON.parse (<anonymous>) at Object.<anonymous>

Jinja Flask issue: Uncaught SyntaxError: Unexpected token { in JSON at position 1 at JSON.parse

Uncaught SyntaxError: Unexpected token d in JSON at position 0 at JSON.parse (<anonymous>)