uncaught syntaxerror unexpected token U JSON uncaught syntaxerror unexpected token U JSON json json

uncaught syntaxerror unexpected token U JSON


That error is normally seen when the value given to JSON.parse is actually undefined.So, I would check the code that is trying to parse this - most likely you are not parsing the actual string shown here.


I was getting this message while validating (in MVC project).For me, adding ValidationMessageFor element fixed the issue.

To be precise, line number 43 in jquery.validate.unobtrusive.js caused the issue:

  replace = $.parseJSON(container.attr("data-valmsg-replace")) !== false;


The parameter for the JSON.parse may be returning nothing (i.e. the value given for the JSON.parse is undefined)!

It happened to me while I was parsing the Compiled solidity code from an xyz.sol file.

import web3 from './web3';import xyz from './build/xyz.json';const i = new web3.eth.Contract(  JSON.parse(xyz.interface),  '0x99Fd6eFd4257645a34093E657f69150FEFf7CdF5');export default i;

which was misspelled as

JSON.parse(xyz.intereface)

which was returning nothing!