JSON to JSON Comparison Module

The JSON to JSON Comparison Module allows you to compare large, local JSON files with each other. It doesn't matter if the files are complex; the Module takes hierarchies and array objects into account.

The JSON to JSON Comparison Module is part of the Data Integrity subset.

ModuleAttributes

The Module has the following ModuleAttributes:

ModuleAttribute

Description

Filename

Absolute path to your source or target JSON file.

Row Key

[Optional]. Enter a suitable row key to detect moved objects within arrays. The comparison finds the row key and compares all other properties within that object.

Note:

  • The row key can only consist of one property.

  • You can't combine this property with other properties.

The TestCase tries the row key on all objects within arrays.

In the example below, the row key can be either city, country, or id:


  {    
    "city": "Sydney",
    "country": "Australia",    
    "id":1    
  },
  {
    "city": "Vienna",
    "country": "Austria",
    "id":2
  }
]

Result

A successful comparison returns the result Files match*. Enter this as the value and use ActionMode Verify. This verifies the TestCase against the result; if the comparison fails, so does the TestCase.

In this example, you compare two JSON files: Left.json and Right.json.

  • The paths in the Source and Target TestStepValues use a test configuration parameter to define the base directory.

  • The Row Key defines that the comparison should try to find moved objects. It's specifically looking for the property id.

  • With Result, you verify that the comparison was successful.

Compare two JSON files

What's next

Learn how to create TestCases from Modules and put your JSON files to the test:

Alternatively, check out other Tricentis Data Integrity test types to review the quality of your data.