question

MinhPham-9005 avatar image
0 Votes"
MinhPham-9005 asked PramodValavala-MSFT answered

How to know if a variable is Object or Array

Hi, currently I am using Xpath to work on an XML file, and I notice that the return of Xpath can be an object or an array. This will be depended on the input XML file, and I can not control the content of the XML file. So I need to have a condition so that if the Xpath output is an object, I will handle in a way; and if the Xpath output is an array, I will handle in another way. How can I achieve that?

126725-image.png


azure-logic-apps
image.png (80.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT answered

@MinhPham-9005 I believe there isn't any way to get the type of a value in Logic Apps and on top of that - strings, arrays, and objects are all treated as collections.

One way I could think of is to use a method that works only on arrays like length to validate the type. If this expression succeeds, then it's an array otherwise an object (I assume here you don't have a string output from your xpath). You can configure run after in a parallel branch to continue processing as if the value is an object.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.