How to declare a json string correctly?

Viewed 14059

So I tested two ways of declaring a json string:

1:

json = "{'name': 'ajsie'}";
obj = JSON.parse(json); // SyntaxError: Unexpected token ILLEGAL

2:

json = '{"name": "ajsie"}';
obj = JSON.parse(json); // Worked!

What is the problem with the first one?

5 Answers
Related