Evaluate JSON Path Expression V2 Assertion

The Evaluate JSON Path Expression V2 Assertion is an improved version of the . This improved assertion provides the following enhancements:
Evaluate JSON Path Expression V2 Assertion
is an improved version of the Evaluate JSON Path Expression Assertion. This improved assertion provides the following enhancements:
  • More intuitive results when querying JSON objects
  • New evaluators in the assertion properties:
    • SystemDefault
    • JsonPathWithCompression
Place a Protect Against JSON Document Structure Assertion before this assertion to protect against DOS attacks.
Context Variables Created by This Assertion
The Evaluate JSON Path Expression V2 assertion sets the following context variables. The default <prefix> is "jsonPath" and can be changed in the assertion properties.
To learn about selecting the target message for this assertion, see Select a Target Message.
Indicates whether a match was found for the expression:
  • true
    = Match found
  • false
    = No match found
Returns the number of matches.
Returns the result of the match, if a single match was made.
Returns the results of the match, if multiple matches were made.
Using the Evaluate JSON Path Expression Assertion V2
You can either add this assertion to your service or change the configuration of an existing assertion as follows:
  1. Do one of the following:
    • To add the assertion to the Policy Development window, see Add an Assertion. The Evaluate JSON Path Expression V2 Properties will automatically appear.
    • To change the configuration of an existing assertion, right-click
      Evaluate JSON Path Expression V2
      in the policy window and select
      Evaluate JSON Path Expression V2 Properties
      or double-click the assertion in the policy window.
  2. Configure the evaluator and expression, as shown next:
    The following evaluators are supported:
    • System Default:
      The evaluator option is taken from the
      Cluster-Wide Property. This is the default option.
    • JsonPath
    • JsonPathWithCompression
      • If you select
        the value of cluster-wide property
        is not considered.
      • If a JSON object contains a forward slash in the JSON object input, then a backslash is appended to the forward slash in the JSON output. To avoid this, set the evaluator as JsonPathWithCompression.
    Enter the expression to be matched against a message. You may reference context variables.
    The Expression field can only contain a single expression. To evaluate multiple expressions, configure multiple Evaluate JSON Expression assertions within a policy.
  3. Configure
    [Source and Destination]
    tab as follows:
    Target Message
    Specify whether to match the
    , or
    Other Message Variable
    that contains the value to analyze. If you select
    Other Message Variable
    option, enter the variable name in the text box. (You do not need to enclose the variable name within the "${ }" characters.)
    The message target can also be set outside of the assertion properties. For more information, see Select a Target Message.
    Variable Prefix
    Enter a prefix that is added to the context variables created by this assertion. This prefix ensures uniqueness and prevents the variables from overwriting each other when multiple instances of this assertion appear in a policy.
    For an explanation of the validation messages that are displayed, see "Context Variable Validation" in Context Variables.
  4. Select the [
    ] tab to test your JSON expression against sample test input.
    • In the
      Test Input
      box, paste some JSON payload that might be found in the target message. When you click the [
      ] button, the assertion evaluates the test input with the specified expression.
    • The
      Test Output
      box shows the results of the match. Examine the results carefully to see if this is what you intended. The following figure illustrates how the assertion interprets the test input given the sample expression shown:
      • For the test input shown in the figure, the test results are
        found = true
        count = 2
        . This means that there were two inputs that fulfilled the criteria: Nigel Rees and Evelyn Waugh. The assertion was able to locate the author but not the category, title, or price, because they were not specified.
  5. Click [
    ] when done.