> Here is a example JSON:
> 
> var json  = {
>   fields:
>   [
>    {prompt1: "Login Name"},
>    {prompt2: "Real Name"},
>    {prompt3: "Location"},
>    {prompt4: "Password"},
>    {prompt5: "Security Group"},
>    {prompt6: "File Area"}
>   ]
> };

That's not valid JSON. You need double quotes on all the property names.

Obviously it doesn't make any difference if you are just eval'ing it (it is
valid JavaScript), but if anyone uses it with a real JSON parser it will
fail.

> I figured it out know.  You got to look at the constructor type to see
> if its an Object, Array or String.   From there you can decide to use
> for each or for in or for loop.

You don't have to write that code yourself:

http://jollytoad.googlepages.com/json.js

Description from the plugins page (http://docs.jquery.com/Plugins):

hacked the original json.js into a jQuery plugin. It adds the two
functions:$.toJSON(value),$.parseJSON(json_str, [safe]).

See the code for more details.

-Mike

Reply via email to