Dear Kevin,

I fail to understand your question and, seeing that it is completely unanswered for days, I suspect that others face the same problem.

First of all: "COS" is "Caché Object Script", right? Just to make sure we are on the same page here.

There is nothing inherent in ObjectScript  concerning username/password I know of. These are just scripts running on the Caché sever. So, creating the notorious HelloWorld.mac:

    
    write "Hello World"
    quit

it can be executed from the terminal command prompt:

mycache:USER>do ^HelloWorld
Hello World
mycache:USER>

Could you maybe provide some context and - preferably - a (sanitized) example? 

Regards

Matthias

I would recommend a different structure to the JSON since an array node can hold both, a value and subnodes. This should be reflected in the JSON. So, for an array:

a(1)="A"
a(1,1)="AA"
a(1,2)="AB"
a(1,2,1)="ABA"
a(1,3,1)="ACA"
a(2,1)="BA"
a(3)="C"
a(3,1)="CA"
I suggest to generate an JSON in the form: 

{"1":["A",{"1":["AA"],"2":["AB",{"1":["ABA"]}],"3":[{"1":["ACA"]}]}],"2":[{"1":["BA"]}],"3":["C",{"1":["CA"]}]}

This may not be the most convenient for the receiving end to read, but it can hold the full information from the array. This can easily be created using a recursive procedure:

 /// Converts an arbitrary array into an JSON-Structure returned
/// as %DynamicObject. Subnodes are read recursively, so there 
/// might be a limit tothe number of levels that can be read.
///
/// Usage example:
/// >set a(1)="A"
/// >set a(1,1)="AA"
/// >set a(1,2)="AB"
/// >set a(1,2,1)="ABA"
/// >set a(1,3,1)="ACA"
/// >set a(2,1)="BA"
/// >set a(3)="C"
/// >set a(3,1)="CA"
///
/// >write $$^Array2JSON(.a).%ToJSON()
/// {"1":["A",{"1":["AA"],"2":["AB",{"1":["ABA"]}],#
/// "3":[{"1":["ACA"]}]}],"2":[{"1":["BA"]}],"3":["C",{"1":["CA"]}]}
///
/// I: &array: reference to the array
///
/// O: JSON: %DynamicObject holding the indices as keys and node
///  values and 
/// subnodes in %DynamicArrays
Array2JSON(&array) Public
{
set JSON = ##class(%DynamicObject).%New()
set key = $order(array(""))
while ( key'="" )
{
// create a new entry
set subJSON = ##class(%DynamicArray).%New()
if ( $get(array(key))'="" )
{
do subJSON.%Push(array(key))
}
if ( $order(array(key,""))'="" )
{
kill subarray
merge subarray = array(key)
set subarrayJSON = $$Array2JSON(.subarray)
do subJSON.%Push(subarrayJSON)
}
do JSON.%Set(key,subJSON)
set key = $order(array(key))
}
return JSON
}

The  tErrorList is returned as an array.

tErrorList itself (without index) is an increment counter for decomposed stati. The entry tErrorList(i) contains an array with the information with indices "caller", "code", "dcode", "domain", "namespace", "param", "stack" and others. You can inspect it in the console easily using zw tErrorList or go through it using $order() or $query()

If uninitialized the array it will be created.

If initialized to something other than an array it will be killed and a new array created.

If initialized to an appropiate array (e.g. by previous calls of DecomposeStatus()) the error listings will be appended and the counter incremented.

HTH

Matthias

As an additional comment, since this was not clear to me in advance:

The field 'id' is not set in the %Save() (as the %Id() would be with a normal Caché class). This ist reasonable sice neither of the fields 'a' or 'b' in my example ar part of the id and the id is not read from ODBC-connection.

Thus, the object has to be re-opened after the %Save() searching the id using a select on the table specifying a and b.

Regards
Matthias