0 votes
2.0k views
in Javascript by
I dont know whats wrong, but the following always says syntaxerror.

json_encode Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data

const config_list = <?php echo json_encode($config_list); ?>;

const xx = JSON.parse(config_list);

x = xx.COUNTRY["1"];
alert(x);

1 Answer

0 votes
by
That JSON is already parsed. You dont need to parse it again which will produce that error. Remove that line and it should work ok.

Related questions

0 votes
1 answer 2.5k views
+1 vote
1 answer 9.6k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 268 views
0 votes
1 answer 598 views
asked Jul 29, 2016 in Phalcon by Robin
0 votes
1 answer 136 views
asked Oct 29, 2021 in General by anonymous
0 votes
1 answer 205 views
...