[Dojo-interest] JSON Object confusion

Dustin Machi dmachi at dojotoolkit.org
Sat Nov 4 17:45:22 MST 2006


> {"1":"Rhythm","4":"Melody"}
>
I'm not sure, but I doubt you can have labels with the first character 
being a number:

{"one":"Rhythm", "four": "Melody"}


> now I try within a io bind:
> ....
> load: function(type, data, evt) {
> dojo.debug(data); // {"1":"Rhythm","4":"Melody"}
> var dataJSON = dojo.json.evalJson(data);
> dojo.debug(dataJSON); // [object Object]
> dojo.debug(dataJSON.length); // undefined
> 

You don't hafve to do any eval if you set mimetype to "text/json" 
(actually I think we're supposed to use "application/json" now)

mimetype: "application/json",
load: function(type, data, evt) {
	/* data here is the already eval'd object */
}

> comboBox.dataProvider.setData(dataJSON); // doesn't set any data
>

Without looking at the way that combobox expects to see its data, i seem 
to recall it wanting an array of arrays, something like:

so you might return something like

{elements: [  [1, "rhythm"], [4, "melod"] ]}

then do

comboBox.dataProvider.setData(data.elements);



Dustin



More information about the Dojo-interest mailing list