This topic covers previous (pre-9.7) implementations of the JSON Assertor tool, which lets you place assertions on different elements in a JSON message. The previous implementations are deprecated: any existing tools will continue to work, but all new JSON Assertors you add will use the new implementation.

For details on the current tool implementation, see JSON Assertor.

Sections discussing the deprecated tool include:

Understanding JSON Assertor

The JSON Assertor is used to enforce the correctness of data in a JSON message. It enables you to introspect into individual elements in JSON messages and check whether they meet expectations. 

The JSON Assertor can be chained against any tool that communicates a JSON Message, It is most commonly connected with the Messaging Client and REST Client tools.

Configuring JSON Assertor

The JSON Assertor consists of three main tabs:

  • Summary: This tab contains a table showing the details of the JSON Assertions that have been configured.
  • Configuration: This tab is used to create and configure new and existing JSON Assertions.
  • Expected JSON: Specifies the expected JSON message that all assertions will be compared against. If the JSON Assertor receives valid JSON message (i.e. attached to the REST Client), this panel will automatically populate the JSON message in both a Tree and Literal view. Once populated, the expected JSON message can be saved for future uses.

To use the JSON Assertor, complete the following:

  1. Select a project tree node and click Add Output from the shortcut menu. The Add Output wizard displays.
  2. In the Add Output wizard, select Request / Response> Traffic  from the left GUI pane, select JSON Assertor from the right GUI pane, and click the Finish button. A JSON Assertor node is added underneath the selected node.
  3. Click the Add button in the JSON Assertor’s Configuration tab. The Select Assertion wizard displays.



  4. Select an assertion type. The following is a brief summary of the available types of Assertions.
    • Value Assertions: The following value assertions are available:
      • Value Assertion: Enforce the value of a particular element.
      • Numeric Assertion: Enforce the numeric value of an element.
      • String Comparison Assertion: Enforce the value of the text content of a given element.
      • Regular Expression Assertion: Enforce that an element matches a regular expression.
      • Custom Assertion: Enforce the value of an element by scripting custom logic.
    • Structure Assertions: The following structure assertions are available:
      • Has Content Assertion: Enforce that an element has text content (i.e., length of text > 0).
      • Has Children Assertion: Enforce that an element has one or more child elements.
    • Compound Assertions: The following compound assertions are available:
      • AND Assertion: Group multiple assertions that all must succeed.
      • OR Assertion: Group multiple assertions where at least one must succeed.
      • Conditional Assertion: Enforce an assertion only if a condition is met (where the condition is a combination of previously-defined assertions).
    • Difference Assertions: The following difference assertions are available:
      • Numeric Difference Assertion: Enforce a numeric difference on a value of a particular element. Assert that the numeric value of an element differs from a user-specified base value by a user-specified value. For example, in order to assert that a value in degrees Fahrenheit is 3 degrees below freezing, you would set the Base Value to 32 and the Difference Value to -3.
    • Range Assertions: The following difference assertions are available:
      • Numeric Range Assertion: Enforce that the numeric value of an element is within the inclusive bounds of a numeric range.
  5. Click the Next button. A tree view displays.
  6. Select the element that you want this assertion to check, then click the Finish button.

You may add additional assertions to apply to the message by clicking the Add button in the Configuration tab.

If you later want to modify the element referenced by an assertion, click Change Element, which is at the bottom right of the Configuration tab. This opens a dialog that lets you graphically or manually edit the given element. 

  • No labels