Hello Arnar,
maybe i need to explain it more detailed.
var rData= [
{
"VORGANG":"XX1234",
"NR":"572",
"NAME1":"Frank",
"NAME2":"S",
"REISENR":"12345"
},
{
"VORGANG":"XX12344",
"NR":"1111",
"NAME1":"Frank",
"NAME2":"L",
"REISENR":"12345"
},
{
"VORGANG":"XX12345",
"NR":"1264",
"NAME1":"Frank",
"NAME2":"L",
"REISENR":"12345"
}
] ;
and i need it to be transformed to a html-table like
vorgang nr name1 name2 reisenr
XX1234 572 Frank S 12345
XX12344 1111 Frank L 12345
XX12345 1264 Frank L 12345
what i do right now is
var gotData = function(rData) {
row_display = function (row) {
return TR(null, map(partial(TD, null), row));
}
var dataArr = new Array();
forEach(rData, function(rRow) {
dataArr.push(values(rRow));
});
var newTable = TABLE({'id': 'myDataTable'},
THEAD(null,
row_display(keys(rData[0]))),
TBODY(null,
map(row_display, dataArr)));
appendChildNodes('myDisplay', newTable);
}
d = MochiKit.Async.loadJSONDoc("mydemodata.json");
d.addCallback(gotData);
My main question is: isn“t there a more elegant, smooth and flexible
way to transform an object-array to an array than
var dataArr = new Array();
forEach(rData, function(rRow) {
dataArr.push(values(rRow));
});
or even better: can someone give me a hint on how to do the things in
the example on an object instead of first converting it to this array?
hope my question is now more clear.
So long
--frank
On 26 Jan., 11:39, "Arnar Birgisson" <[EMAIL PROTECTED]> wrote:
> On 1/26/07, Johnny Blonde <[EMAIL PROTECTED]> wrote:
>
> > now i need to do something like this with it:
> > var dataArr = items(JSONdata);You can just do eval(JSONdata). That is the
> > beuty of JSON, it's just a
> subset of javascript. Seehttp://www.json.org/
>
> If you use MochiKit's loadJSONDoc this is already done for you, the
> callback will be called with the array you want.
>
> I hope I didn't misunderstand your question, my apologies if I did so.
>
> Arnar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---