R
R
Richard Smith2020-06-18 10:14:02
JavaScript
Richard Smith, 2020-06-18 10:14:02

Why can't I parse JSON?

Hello. I receive a response from the server and cannot parse it, I get an error (SyntaxError: Unexpected token p in JSON at position 0 at JSON.parse). What's my mistake?

parseResults({"response":{"Header":{"Status":"0","TransactionId":"51108941R3873185"},"RecordCount":"9","Records":{"Record":[{"Names":{"Name":[{"First":"BOBBIE","Middle":"E","Last":"ROBINSON","Prefix":"MS"},{"First":"BOBBIE","Middle":"JEAN","Last":"ROBINSON","Prefix":"MS"},{"First":"B","Last":"ROBINSON"},{"First":"BOBBI","Last":"ROBINSON","Prefix":"MS"}]},"Addresses":{"Address":[{"DateLastSeen":{"Year":"2020","Month":"04"},"City":"WINNSBORO","State":"TX","Zip5":"75494","Zip4":"3402","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2006","Month":"07"},"City":"WINNSBORO","State":"TX","Zip5":"75494","Zip4":"2459","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2010","Month":"05"},"City":"MESQUITE","State":"TX","Zip5":"75150","Zip4":"3015","PhoneIndicator":"0"}]},"DOBs":{"Item":{"DOB":{"Year":"1940","Month":"10","Day":"31"},"Age":"79"}},"Relatives":{"Relative":{"bvid":"N_MDAyMTcxNTcyMzg5","First":"ROYCE","Middle":"W","Last":"ROBINSON"}},"bvid":"N_MDAyMTY4ODI0NDE0","link":"http:\/\/results.beenverified.com\/index.php?fn=Bobbie&ln=Robinson&city=WINNSBORO&state=TX&bvid=N_MDAyMTY4ODI0NDE0&bvcid=","exactMatch":"1","hasAge":"1","age":"79"},{"Names":{"Name":[{"First":"BOBBIE","Middle":"E","Last":"ROBINSON"},{"First":"BOBBY","Middle":"E","Last":"ROBINSON"},{"First":"ROBBIE","Middle":"E","Last":"ROBINSON"},{"First":"BOB","Last":"ROBINSON"},{"First":"ROBERT","Last":"ROBINSON"}]},"Addresses":{"Address":[{"DateLastSeen":{"Year":"2020","Month":"04"},"City":"WINNSBORO","State":"TX","Zip5":"75494","Zip4":"3712","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"1984","Month":"06"},"City":"DALLAS","State":"TX","Zip5":"75221","Zip4":"0195","PhoneIndicator":"0"},{"City":"COMO","State":"TX","Zip5":"75431","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"1993","Month":"02"},"City":"TYLER","State":"TX","Zip5":"75703","Zip4":"3662","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2003","Month":"10"},"City":"TYLER","State":"TX","Zip5":"75703","Zip4":"4552","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2011","Month":"03"},"City":"DALLAS","State":"TX","Zip5":"75224","Zip4":"2533","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2006","Month":"05"},"City":"COMO","State":"TX","Zip5":"75431","PhoneIndicator":"0"},{"DateLastSeen":{"Year":"2003","Month":"06"},"City":"COMO","State":"TX","Zip5":"75431","Zip4":"2313","PhoneIndicator":"0"}]},"DOBs":{"Item":[{"DOB":{"Year":"1928","Month":"12","Day":"10"},"Age":"91"},{"DOB":{"Year":"1929","Month":"12","Day":"10"},"Age":"90"}]},"Relatives":{"Relative":[{"bvid":"N_MDQxMzc1MDM4MDMz","First":"JORDAN","Middle":"W","Last":"ROBINSON"},{"bvid":"N_MDAyMTYxNDE3ODk0","First":"ROBERT","Middle":"W","Last":"ROBINSON"}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2020-06-18
@Klimsava

What is your error written in the message about it:

Unexpected token p in JSON at position 0 at JSON.parse

It says that the zero (which means the very first in a row) character for the json parser turned out to be unexpected. Its value is "p" - this is indicated right there in this message. Now look at what you have as the first character in your supposedly JSON:
parseResults({"response":{"Header":

What a surprise! It's the letter "p"!
You are trying to parse something that is not JSON. A document of this format cannot begin like this.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question