I believe the other replies have overcomplicated the issue quite a bit.

This is your own server you're getting the data from, right? Then you don't
need to worry about security. There's nothing to decode, you don't need any
plugins, and you don't need to use eval().

Simply use code like this:

    $.getJSON( 'myjson.php', function( json ) {
        var jval = json.jval;
        var wine = jval.wine;  // 3
        var sugar = jval.sugar;  // 4
        var lemon = jval.lemon;  // 22
        // or:
        var lemon = json.jval.lemon;  // 22
    });

As you can see, accessing the JSON data works *exactly* the same way as if
you'd written code like this (forget jQuery and JSON, just straight-up
JavaScript code):

    var json = {
        jval: {
            wine: 3,
            sugar: 4,
            lemon: 22
        }
    };

    alert( json.jval.lemon );  // 22

-Mike

> From: Bluesapphire
> 
> Hi!
>     I am novice to Jquery.
> Iam getting following Json output from PHP file :
> 
> {"jval":{"wine":3,"sugar":4,"lemon":22}}
> 
> how can I decode/get these Json values in Jquery.
> 
> Thanks in advance
> 

Reply via email to