Hi,
I am using the extract variable policy to fetch variable from JSON payload. But here I want to check conditions like JSON payload has array kind of response or not.
Could you confirm anyone, is it possible or not?
You can detect if the payload is an array or not by using this simple Extract Variables policy:
<ExtractVariables continueOnError="false" enabled="true" name="Extract-Variables"> <DisplayName>Extract Variables</DisplayName> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <JSONPayload> <Variable name="array"> <JSONPath>$.[0]</JSONPath> </Variable> </JSONPayload> <Source clearPayload="false">request</Source> </ExtractVariables>
Then in a subsequent step you can use a Condition to check the array variable:
<Request> <Step> <Name>Extract-Variables</Name> </Step> <Step> <Condition>array != null</Condition> <Name>Raise-Fault-I-Am-Array</Name> </Step> </Request>