Digital Fusion
Digital Fusion

Reputation: 165

Invalid JSON - Cannot see why

The following JSON string comes back as invalid in several formatter tests. I cannot figure out for the life of me what is wrong!

{
"draw": 122, 
"recordsTotal": 1496, 
"recordsFiltered": 1496, 
"data": [["11315","1403","John Doe","Parking Pass","-","Hyundai Sonata - Grey ABC 123   ","09-01-2016 2:00 AM","09-01-2016 7:00 AM","-"]] 
}

https://jsonformatter.org/ is saying:

Parse error on line 5: ...,"Parking Pass","-","Hyundai Sonata - Gr -----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'

https://jsonformatter.curiousconcept.com/ says:

Error:Invalid characters found.[Code 18, Structure 28] and highlights the line "Hyundai Sonata - Grey ABC 123 ",

What the heck am I missing? I dont see any invalid characters anywhere. If I paste it into Notepad++ its not showing anything but "CRLF" on the line breaks.

Upvotes: 1

Views: 671

Answers (1)

Digital Fusion
Digital Fusion

Reputation: 165

After checking, it turns out that the value, which was being returned from a database, had a tab in it. I created a function to strip out any non ASCII chars and its working fine now

Upvotes: 1

Related Questions