On Aug 31, 5:26 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > Mark Gibson wrote a lightweight jQuery plugin with $.toJSON() and
> > $.parseJSON():
> >http://jollytoad.googlepages.com/json.js
>
> Actually, Douglas "JSON" Crockford wrote the original code, so it's been
> well tested and proven:
> > > Here is a example JSON:
> > >
> > > var json = {
> > > fields:
> > > [
> > >{prompt1: "Login Name"},
> > >{prompt2: "Real Name"},
> > >{prompt3: "Location"},
> > >{prompt4: "Password"},
> > >{prompt5: "Security Group"},
> > >{prompt6: "File Area"}
> > > ]
> > >
On Aug 31, 4:51 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > Here is a example JSON:
>
> > var json = {
> > fields:
> > [
> >{prompt1: "Login Name"},
> >{prompt2: "Real Name"},
> >{prompt3: "Location"},
> >{prompt4: "Password"},
> >{prompt5: "Security Group"},
> >
On Aug 31, 2:37 pm, "John Beppu" <[EMAIL PROTECTED]> wrote:
> > 2) Best way to create a toJSON() string or object.
>
> anyObject.toSource()
Hi John,
Yes, at first, that is what I thought and at first, i said "Ah ha!,
thats it!"
But its not quite right for all situations and worst, atleast up
Michael Geary wrote:
> > IE doesn't like:
> >
> > json = {};
> >
> > but will accept:
> >
> >var json = {};
>
> Let me take a guess...
>
> You are executing this code inside a function, and you have an HTML element
> in your page with the id 'json'.
> ...
> Did I get it right?
Gawd, I sh
> > > From: Pops
> > > I figured it out know. You got to look at the
> > > constructor type to see if its an Object, Array
> > > or String. From there you can decide to use
> > > for each or for in or for loop.
> > From: Michael Geary
> > You don't have to write that code yourself:
> > http:/
> From: Pyrolupus
>
> Mark Gibson wrote a lightweight jQuery plugin with $.toJSON() and
> $.parseJSON():
>
> http://jollytoad.googlepages.com/json.js
>
> I haven't tried it out, yet, but it looked good at a cursory glance.
Actually, Douglas "JSON" Crockford wrote the original code, so it's bee
Michael Geary wrote:
> > I figured it out know. You got to look at the constructor type to see
> > if its an Object, Array or String. From there you can decide to use
> > for each or for in or for loop.
>
> You don't have to write that code yourself:
>
> http://jollytoad.googlepages.com/json.j
> Here is a example JSON:
>
> var json = {
> fields:
> [
>{prompt1: "Login Name"},
>{prompt2: "Real Name"},
>{prompt3: "Location"},
>{prompt4: "Password"},
>{prompt5: "Security Group"},
>{prompt6: "File Area"}
> ]
> };
That's not valid JSON. You need double quotes
> 2) Best way to create a toJSON() string or object.
> I didn't see a direct way to do this, if not, is this best way:
>// Create JSON from form input id="wc*" fields
>
>$jj = $('[EMAIL PROTECTED]').get();
>json = {};
>try {
> for (var j=0; j <$jj.length; j++) {
> j
>
> 2) Best way to create a toJSON() string or object.
anyObject.toSource()
Klaus Hartl wrote:
> Yes, there is a direct method, just use a for loop:
>
> for (var key in json) {
> console.log(key); // key
> console.log(json[key]); // value
> }
>
> Maybe I didn't get the question right?
Hi Klaus,
Ok, Now I see why I asked the question. Yes, I did try the abov
Klaus Hartl wrote:
> I'm going to answer the first question (low hanging fruit)...
:-)
> Yes, there is a direct method, just use a for loop:
>
> for (var key in json) {
> console.log(key); // key
> console.log(json[key]); // value
> }
>
> Maybe I didn't get the question right?
I don
Pops wrote:
Now that getting a handle on the JS/jQuery language, I have these
basic questions
1) For an JSON object, how do you get the key name?
Example
var json = {field1: "data2", field2: "data2"};
I know how to get the data, but how do you get the field names? IOW, I
want to get the nam
14 matches
Mail list logo