If you import JSON like this:

{
          "colormeds": {
                   "progress": {
                             "level": "1",
                             "cycle": "1"
                   },
                   "colorwheel": {
                             "Red": "255,0,0",
                             "Red-Orange": "255,64,0",
                             "Orange": "255,127,0",
                             "Orange-Yellow": "255,191,0",
                             "Yellow": "255,255,0",
                             "Yellow-Green": "191,255,0",
                             "Green": "0,255,0",
                             "Green-Blue": "0,191,255",
                             "Blue": "0,0,255",
                             "Blue-Violet": "127,0,255",
                             "Violet": "127,0,127",
                             "Red-Violet": "191,0,127"
          }
}

the keys for:

sConfigColor["colormeds"]["colorwheel"]  are returned as expected in a hashed 
order


Blue

Orange-Yellow

Violet

Green

Green-Blue

Red-Violet

Blue-Violet

Red

Yellow

Red-Orange

Orange

Yellow-Green


is there a simple method for restoring the sequential order as entered in the 
JSON? or a way to store in the JSON that facilitates that requirement?

I solved it by put the values into an array, with a extra delimited, but this 
seems "hacky" but can now order the keys because they default to numeric index

"colorwheel": [
                             "Red|255,0,0",
                             "Red-Orange|255,64,0",
                             "Orange|255,127,0",
                             "Orange-Yellow|255,191,0",
                             "Yellow|255,255,0",
                             "Yellow-Green|191,255,0",
                             "Green|0,255,0",
                             "Green-Blue|0,191,255",
                             "Blue|0,0,255",
                             "Blue-Violet|127,0,255",
                             "Violet|127,0,127",
                             "Red-Violet|191,0,127"]
                   },

Now I have to set the delimiter to pipe and then fetch the item…
Is there a better way?



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to