From: jdalton on
The jQuery support list is here:
http://groups.google.com/group/jquery-en
From: Thomas 'PointedEars' Lahn on
Jorge wrote:
> On May 5, 3:07 pm, jdalton <John.David.Dal...(a)gmail.com> wrote:
>> The jQuery support list is here:http://groups.google.com/group/jquery-en
>
> The json support list is here:
> http://tech.groups.yahoo.com/group/json/

Peer reviews are included here:
http://groups.google.com/groups?q=%22Prototype%22+%28jquery%29+group%3Acomp.lang.javascript&scoring=d&filter=0


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Jorge on
On May 5, 3:07 pm, jdalton <John.David.Dal...(a)gmail.com> wrote:
> The jQuery support list is here:http://groups.google.com/group/jquery-en

The json support list is here:
http://tech.groups.yahoo.com/group/json/
From: "Jon Paal [MSMD]" Jon nospam Paal on
A solution to the original json structure:

success: function(json, status) {
var records = json.Records;
var str = "";
if(records ){
for(var i = 0; i < records.length; i++){
for(var j in records[i]){
str += j + " --> " + records[i][j] + "\n";
}
}
alert(str);
}





"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message news:McCdnX-gdIMbmIPVnZ2dnUVZ_s-pnZ2d(a)palinacquisition...
> using json like
>
> ( {"Records": [ {"firstname":"Nancy","lastname":"Davolio"} ], "RecordCount":"1" } )
>
> and jquery like:
>
> $.ajax({
> ...
>
> success: function(json, status) {
> if(json.Records){alert("firstname= "+json.Records.firstname );}
> ...
>
> I can retrieve values for firstname if I use the reference spelled out
>
> is there a way to get it by numerical position, something like:
>
> if(json.Records){alert("firstname= "+json.Records.0 );}
>
> except it would work .. :)
>
> thanks in advance
>


From: Jorge on
On May 6, 5:27 am, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
com> wrote:
> A solution to the original json structure:
>
> success: function(json, status) {
>   var records = json.Records;
>   var str = "";
>   if(records ){
>    for(var i = 0; i < records.length; i++){
>     for(var j in records[i]){
>      str += j + " --> " + records[i][j] + "\n";
>     }
>    }
>   alert(str);
>   }
>

Yep !

Still, I'd consider that :

{"Records":
[{"firstname":"Nancy","lastname":"Davolio"}],"RecordCount":"1"}

contains as much info as :

[["Nancy","Davolio"]]

Bus is almost 3x longer.

If you want the headers, you can save them into Records[0] (and keep
sending them but only once) :

[["firstname","lastname"],["Nancy","Davolio"]]

Which still is more compact than the original structure :

[["firstname","lastname"],["Nancy","Davolio"]]
{"Records":
[{"firstname":"Nancy","lastname":"Davolio"}],"RecordCount":"1"}

and tends to be still more compact as the # of records go up : 175 vs
340 chars. (~50%)

[
["firstname","lastname"],
["Nancy","Davolio"],
["Nancy","Davolio"],
["Nancy","Davolio"],
["Nancy","Davolio"],
["Nancy","Davolio"],
["Nancy","Davolio"],
["Nancy","Davolio"]
]

==

{"Records":[
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"},
{"firstname":"Nancy","lastname":"Davolio"}],
"RecordCount":"3"}

And the code is almost the same :

success: function(json, status) {
var i, j, r = json, str = "";
if (r) {
for (i=1; i<r.length; i++) {
for (j=0; j<r[i].length; j++) {
str += r[0][j] + " --> " + r[i][j] + "\n";
}
}
alert (str);
}

--Jorge.