javascriptjqueryjson

JSON problem solution


I have this fiddle. I want to alert the background. How can I?

Thanks.


Solution

  • Two problems:

    1. You must eval the JSON string to get an object.
    2. The background value is missing quotes.

    It works like this:

    var gib = eval("({background:'default.jpg'})");
    alert(gib.background)