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

623Re: [json] json as js variable

Expand Messages
  • Martin Cooper
    Dec 10, 2006
    • 0 Attachment
      On 12/10/06, Mark Ireland <markincuba@...> wrote:
      >
      >
      > Thanks. I was hoping there was a js function library where you just pass
      > the
      > unique id and the row is returned.
      > Is there one?


      What do you mean? There is no concept of "row" in JSON, or even unique IDs,
      for that matter, beyond the property names in an object. Any structure you
      are imposing on your JSON objects is your own, so there isn't going to be a
      library out there to manipulate that unless you write it. ;-)

      --
      Martin Cooper


      >From: "Martin Cooper" <mfncooper@...>
      > >Reply-To: json@yahoogroups.com
      > >To: json@yahoogroups.com
      > >Subject: Re: [json] json as js variable
      > >Date: Sat, 9 Dec 2006 15:51:40 -0800
      > >
      > >On 12/9/06, Mark Ireland <markincuba@...> wrote:
      > > >
      > > >
      > > > Is there any javascript code for finding a json variable by its key?
      > >
      > >
      > >It's just a JavaScript object, so you can access pieces of it in the same
      > >way as you would with any other JavaScript object. There's no magic.
      > >
      > >say jsonStuff.DATA.UNIQUEID[uniqueid]
      > >
      > >
      > >Without knowing what your data structure looks like, it's kinda hard to
      > >tell
      > >if this is valid or not, but if all the right objects exist in all the
      > >right
      > >places, sure, that would be valid code.
      > >
      > >--
      > >Martin Cooper
      > >
      > >
      > > >From: Jesse Skinner <jesse@...>
      > > > >Reply-To: json@yahoogroups.com
      > > > >To: json@yahoogroups.com
      > > > >Subject: Re: [json] json as js variable
      > > > >Date: Thu, 07 Dec 2006 20:32:47 -0500
      > > > >
      > > > >Hi Mark,
      > > > >
      > > > >Perhaps instead of:
      > > > >
      > > > > for (var j in jsonStations.RECORDCOUNT) {
      > > > >
      > > > >you should try:
      > > > >
      > > > > for (var j=0;j < jsonStations.RECORDCOUNT;j++) {
      > > > >
      > > > >? I'm not sure without seeing your JSON, but this is my best guess.
      > > > >
      > > > >All the best,
      > > > >
      > > > >Jesse
      > > > >http://www.thefutureoftheweb.com
      > > > >
      > > > >Mark Ireland wrote:
      > > > > > I have initialised a json string as a js variable and this simple
      > >test
      > > > >is
      > > > > > working:
      > > > > >
      > > > > > a href="##"
      > > > > >
      > > > >onclick="alert(typeof(jsonStations.DATA.MYVARIABLE
      > > > [0].toString()))">myJSONVariable</a
      > > > > > a href="##"
      > > > > >
      > > > >onclick="alert(typeof(jsonStations.RECORDCOUNT))">
      > > > myJSONObject.recordcount</a
      > > > > >
      > > > > > But this does not:
      > > > > >
      > > > > > function findNumChecked() {
      > > > > > var num = 0;
      > > > > > var chk = null;
      > > > > > for (var j in jsonStations.RECORDCOUNT) {
      > > > > > id = jsonStations.DATA.MYVARIABLE[j].toString();
      > > > > > chk = document.getElementById(id);
      > > > > > if (chk && chk.checked) num++;
      > > > > > }
      > > > > > return num;
      > > > > > }
      > > > > >
      > > > > > What am I missing?
      > > > >
      > > >
      > > > _________________________________________________________________
      > > > Advertisement: Meet Sexy Singles Today @ Lavalife - Click here
      > > >
      > > >
      > >
      > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D23769&_t=754951090&_r=endtext_lavalife_dec_meet&_m=EXT
      > > >
      > > >
      > > >
      > > >
      > > > Yahoo! Groups Links
      > > >
      > > >
      > > >
      > > >
      > >
      > >
      > >[Non-text portions of this message have been removed]
      > >
      >
      > _________________________________________________________________
      > Advertisement: Meet Sexy Singles Today @ Lavalife - Click here
      >
      > http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Flavalife9%2Eninemsn%2Ecom%2Eau%2Fclickthru%2Fclickthru%2Eact%3Fid%3Dninemsn%26context%3Dan99%26locale%3Den%5FAU%26a%3D23769&_t=754951090&_r=endtext_lavalife_dec_meet&_m=EXT
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >


      [Non-text portions of this message have been removed]
    • Show all 19 messages in this topic