Original Message:
Sent: Jul 18, 2024 07:09 AM
From: WhiteForEver
Subject: Receive array from PS Host / getRootObject()
Hi,
Please take a look if that can help or can be a base for what you need to get.
var psData = [{ "scope1": 11 }, { "scope2": 22 }];for each(psDataItem in psData) { var key = Object.keys(psDataItem)[0] var value = psDataItem[key]; System.log("key: " + key + ", value: " + value); }
------------------------------
If you find the answer helpful, please click on the RECOMMEND button.
Please visit my blog to get more information: https://www.clouddepth.com
Original Message:
Sent: Jul 17, 2024 09:50 AM
From: thork
Subject: Receive array from PS Host / getRootObject()
Hello,
I am struggling understanding the getRootObject() on a received PS object. I have read the previous threads here, but they dont make it clear for me.
In my PS code, I return an array with a set of associate arrays.
Outputting the object with System.log(JSON.stringify(psData, null, 4)); I get:
[ { "scope1": 11 }, { "scope2": 22 } ]
Running:
for each (psDataItem in psData)
{
System.log(psDataItem);
}
I get
HashMap:1300406423
HashMap:1806090958
which must be the two entries.
How can I access the entries, e.g. keys, values etc and pull key name and value?
I can do with JSON, but I find it quite complex to navigate in the json object returned by getAsJson()
So shortly said, is it possible to read the entries of the two HashMaps?
Many thanks and regards, K