I
I
Ingerniated2016-10-12 16:13:52
JSON
Ingerniated, 2016-10-12 16:13:52

What is the point of the JSON.parse method here?

Tell me, please, what's the point of adding JSON.parse(text) here, if the same thing can be done by referring directly to the object?
var text = '{"name":"John Johnson","street":"Oslo West 16","phone":"555 1234567"}';
var obj = json parse(text);
document.getElementById("demo").innerHTML =
obj.name + "
" +
obj.street + "
" +
obj.phone;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2016-10-12
@Ingernirated

if the same thing can be done by referring directly to the object?
Try it yourself before asking a question.
hint: text is a string, not an object.
if text is declared an object, then JSON.parse is not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question