Need JSON help

jpan's Avatar

jpan

03 Mar, 2011 05:52 AM

I'm using ColdFusion to generate JSON. The script returns:

[{"SUGGEST":"heal","VAL":"1_v"},{"SUGGEST":"heel","VAL":"2_v"},{"SUGGEST":"hell","VAL":"3_v"},{"SUGGEST":"held","VAL":"4_v"},{"SUGGEST":"helm","VAL":"5_v"}]

I haven't found very much documentation on the required JSON, so the above example is a result of a couple hours of playing around and doing some debugging with Firebug. I'm pretty sure I need to align the options "selectedValuesProp" and "selectedItemProp" with my JSON. I am using:

selectedValuesProp: 'VAL',
selectedItemProp: 'SUGGEST',

It's important to note that ColdFusion serializes JSON using all UPPER-CASE variable names. This is problematic because I noticed on line 263 (in jquery.autoSuggest.js)"

if(opts.searchObjProps == "value")

This test is not case sensitive, so it will pass even though the property is upper case "VALUE" in the JSON data, which will cause a problem. So to get around this, I am using different property names. And for some reason, I can't wrap my head around the definition of these options.

selectedItemProp: string ("value" by default) - Name of object property to use as the display text for each chosen item.

(Q: WHAT IS "EACH CHOSEN ITEM?)

selectedValuesProp: string ("value" by default) - Name of object property to use as the value for each chosen item. This value will be stored into the hidden input field.

(Q: AGAIN, WHAT IS "EACH CHOSEN ITEM?)

searchObjProps: string ("value" by default) - Comma separated list of object property names. The values in these objects properties will be used as the text to perform the search on.

(Q: TO PERFORM WHAT SEARCH ON?)

And finally, given the item:

{value: "21", name: "Mick Jagger"},

What is the purpose of the "value" field?

Any help is appreciated!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac