Loading ...
Sorry, an error occurred while loading the content.

625Re: [json] json as js variable

Expand Messages
  • Jesse Skinner
    Dec 10, 2006
      It sounds like you want to use a JavaScript object, with your uniqueID
      column as the key. What you'd do is somehow structure your JSON like so:

      {
      "uniqueID1": {
      "EM": 12,
      ......
      "Y": 136
      },

      "uniqueID2": {
      "EM": 5,
      ......
      "Y": 188
      },
      }

      then if this object is JSON, you could access JSON['uniqueID1'].EM where
      uniqueID1 is of course one of your unique IDs.

      If you really want to keep your JSON structure, you could loop over it
      once and create a JavaScript object like I've illustrated, and use that
      instead for your lookups.

      Hope that helps,

      Jesse Skinner
      http://www.thefutureoftheweb.com/

      Mark Ireland wrote:
      > Here is one I prepared earlier:
      >
      > {"RECORDCOUNT":30,"COLUMNLIST":"EM,EY,ISSILO,ISWEATHER,LATITUDE,LONGITUDE,PERCENTCOMPLETE,PERCENTQUALITY,SM,UNIQUEID,STATIONNAME,SY,X,Y","DATA":{"EM":[12,5,12,4,10,10,10,10,10,10,10,10,10,10,10,12,10,10,9,12,11,11,12,12,12,10,10,9,3,10],"EY":[2005,2005,2005,2006,2006,2006,2006,2006,2006,2006,2006,2006,2006,2006,2006,2006,2006,.
      >
      > . . . . . .
      > .....,"X":[291,28,152,171,109,96,268,126,250,123,174,188,199,251,91,238,147,274,97,274,126,167,100,145,207,146,120,160,241,232],"Y":[136,188,197,226,212,211,128,113,126,179,197,175,176,148,51,147,252,153,66,180,224,158,83,73,122,131,151,250,178,134]}};
      >
      > I could just loop through this testing for my uniqueID but surely someone
      > has written something quicker and more reusable than that? Is this not a
      > standard structure?
      >
    • Show all 19 messages in this topic