Login Register

dojox.collections.Dictionary: retrieve JSON string

I'm creating a multi-dimensional dictionary collection during runtime. How can I retrieve the native JSON structure (in a string) after the dictionary is build?

You can recreate it using an Iterator.

The collections ctors deliberately mask/hide the initial data used to create the collections themselves; this was by design. If you are looking for some way of dealing with a pure JSON structure, I'd suggest one of the data stores in DojoX.data, such as JSONPathStore.

Keep it simple.

I like the simplicity of the dictionary collection. Does it make sense to add methods to retrieve a native JSON structure or JavaScript array from a dictionary instance?

The array-based collections have a toArray method...

...but the key-value pair based ones do not. Probably best if you assembled it yourself using the Iterator, as I'm not convinced that adding that is a wise thing (though I understand why you might want it).

toArray, toJSON for all collections

Just to make it transparent and easy to use, please make toArray and toJSON for all collections.