Wednesday, January 28, 2009

[jQuery] Re: How to decode Json value through Jquery

If you use AJAX to get your data, take a look at: jQuery.getJSON()
http://docs.jquery.com/Ajax/jQuery.getJSON

If your JSON data came from another source, suppose your JSON data are
stored in a string variable called json, you can simply do:
eval("var obj="+json);
then the variable obj will hold the decoded JSON data.
However this method is quite insecure if the data came from an
untrusted source (e.g. over the Internet). Therefore I would recommend
to use the secureEvalJSON() method of the json plugin.
http://code.google.com/p/jquery-json/

by(e)
Stephan


2009/1/28 Bluesapphire <michealg911@gmail.com>:
>
> 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

No comments: