I’m a beginner with Json, I follow this tutorial
the example I have written is based on the tutorial, but I do not understand it does not work :
<script language="javascript">
var Jtext="{"variables":["var1","var2","var3"]}";
var Jobj=eval("(" + Jtext + ")");
var j=Jobj["variables"];
document.write(j[0]);
</script>
Any helps…
Remove the evil eval and the double quotes on that JSON Obj.
What’s wrong in Your example:
This doesn’t work.
variables,var1,var2, … are out of the string, like the syntax highlight shows us here. That leads to a Uncaught SyntaxError: Unexpected identifier.