0 votes
7.2k 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 3.0k views
+1 vote
1 answer 10.0k views
asked May 11, 2017 in Jquery by Jasna
0 votes
1 answer 1.2k views
0 votes
1 answer 1.0k views
asked Jul 29, 2016 in Phalcon by Robin
0 votes
1 answer 634 views
asked Oct 29, 2021 in General by anonymous
0 votes
1 answer 793 views
...