I would like to make a json from a temp-table that combines fields for two or more tables. I know I can do this dynamicly but wonder if anyone have another way of accomplish this.
i.e. SportsDB with Customer and Salesrep.
I would like to use the tth:write-json(). What I am thinking of now is to walk through the two tables Customer and Salesrep, and add all fields from first table, and add one from the salesrep by making a function that gives the two tables + an extra parameter for the fields that should be added, or just add all fields (exept the one that allready is in customer (salesrep field).
Is there an easier way of doing this?
Thanks for opening my eyes :-) I just did a myJson:Read(bhCustomer). myJson:Add('Salesrep',bhSalesrep::Salesrep), and voila, I got it...
Thanks !!
Peter, after reading I am kind of strugling to understand how to add a "Customer": in front of the JsonArray:write(). I am not able to see any way of adding that... feels a bit stupied :-)
aah :-) thanks... thats the way
Ok Peter, I give up.... I thought I had a solution, but I don't understand why the following happens...
for each wdProcess, first wdProcessType of wdProcess:
oObject:read(buffer wdProcess:handle).
oObject:add("ProcessTypeName",buffer wdProcessType::ProcessTypeName).
oArray:add(oObject).
end.
oHeader:Add('Process',oArray).
oHeader:write(myLC,true).
message string(myLC) view-as alert-box.
I get a lot of records, but they all are the same value as the last record. I have tried to add with index, but no go. What am I doing wrong?
And then I found it :-)) Of course I was overwriting the same oObject ... when I added oObject = NEW oObject(). I got it to work ....