Compare JSON Content

The Compare JSON Content action in the Avo Assure is found under the @Generic Element is used to verify the two JSON content from different file path and save the result in the given output variable.

Syntax

Input: <Filepath-Original file>;<Filepath-File to Compare>;<selective>(Optional)

  • Selective: It fetches only specific parts of the content that will be stored in the output variable.

Output: <Filepath-File to write output>(Optional)<Dynamic Variable>(Optional);<Dynamic Variable>(Optional)

Note: The file name should not be too long.

Usecase/Example

Scenario

When you need to confirm that the order data displayed in an online shopping app is correct, a “Compare JSON Content” action is used. This process checks whether the JSON data from the order system’s API matches an expected JSON file with accurate details. Each time an order is placed, the Avo Assure runs, immediately identifying any errors, such as incorrect product quantities, prices, or delivery dates. This approach speeds up testing and ensures that users see accurate order information without requiring manual inspections.

Input

Provide the following input to compare the two files, as shown below:

C:\Users\Downloads\run2.json;C:\Users\Downloads\run2.json

XML Content:

{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}};{"menu": {
  "id": "file",
  "value": "File",
  "popup": {
    "menuitem": [
      {"value": "New", "onclick": "CreateNewDoc()"},
      {"value": "Open", "onclick": "OpenDoc()"},
      {"value": "Close", "onclick": "CloseDoc()"}
    ]
  }
}}

Expected Result

It should Display the result as files contents are same.

Output

The result of Compare JSON Content action is stored in the {result} output variable as “True”, which can be utilized for display or other purposes.

Last updated

Was this helpful?