> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/generic/file-and-folder-operations/compare-inputs.md).

# Compare Inputs

This is a pre-built Action located under the **@Generic** Element. The functionality of this Action in Avo Assure is to compare the input values and store the identified differences in a dynamic variable.

## **Syntax**

**Input Value**: `<Input(Original)>;<Input(Changed)>;<Selective/All(Optional)>`&#x20;

{% hint style="info" %}
**Note**: **Supported Inputs**:

* The action supports the following input formats:
  * **.json** (file or text)
  * **.xml** (file or text)
  * **text**
* The **Compare Input** action supports the following input combinations for comparison:
  * **File** vs **File**: Compare content between two **.json** or **.xml** files.
  * **File** vs **Static Input**: Compare a **.json** or **.xml** file with static input content.
  * **Response** vs **File Content**: Compare an API/WebService response stored in a dynamic variable with a **.json** or **.xml** file.
* During comparison, the action validates:
  * Exact match.
  * Structural or content differences.
  * Value mismatches.
  * Missing or additional content.
    {% endhint %}

| Argument                                         | Description                                                                                |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------ |
| <p>\<Input Text (Original)></p><p>(Required)</p> | Provide the original input text or file that needs to be compared.                         |
| <p>\<Input Text (Changed)><br>(Required)</p>     | Provide the updated or modified input text or file to compare with the original text.      |
| \<Selective/All(Optional)>                       | Provide **Selective** to compare specific changes or **All** to compare all input changes. |

**Output Value**: ``<Dynamic Variable>;<Dynamic Variable>(`Optional)``

| Argument                                 | Description                                                       |
| ---------------------------------------- | ----------------------------------------------------------------- |
| <p>\<Dynamic Variable><br>(Required)</p> | This dynamic variable holds the result of the content comparison. |
| <p>\<Dynamic Variable><br>(Optional)</p> | This dynamic variable stores the status as **True** or **False**. |

{% hint style="info" %}
**Note**: The output format for **Compare Files** and **Compare Inputs** actions is as follows:&#x20;

* For JSON and Text: \
  The output displays the differences using the following indicators:&#x20;
  * **-** : Indicates that a line is removed from the first input.&#x20;
  * **+** : Indicates that a line is added in the second input.&#x20;
  * **?** : Indicates the delta (difference) between the two inputs.&#x20;
* For xml: \ tags will be there with the following params: \
  The output displays XML differences using the following tags:&#x20;
  * `diff:update-attr` : Indicates that an XML attribute is updated.&#x20;
  * `diff:delete` : Indicates that a line is deleted.&#x20;
  * `diff:insert` : Indicates that a line is inserted.&#x20;
  * `diff:delete-attr` : Indicates that an XML attribute is deleted.&#x20;
  * `diff:add-attr` : Indicates that an XML attribute is added.&#x20;
    {% endhint %}

### **Example 1: Comparing Two JSON Files**

In this example, we explain how to compare the content of two JSON files.

* **Action:** Compare Inputs
* **Input Value:** C:\TestData\Request.json;C:\TestData\ExpectedRequest.json
  * The first argument (**C:\TestData\Request.json**) specifies the original JSON file.
  * The second argument (**C:\TestData\ExpectedRequest.json**) specifies the JSON file to compare.
* **Output Value:** {ComparisonResult}
  * The first output variable (**{ComparisonResult}**) stores the comparison result.
  * If a second output variable is provided, the action returns the status as **True** or **False**:
    * **True**: If the comparison executes successfully.
    * **False**: If the comparison fails due to invalid file path, missing file, or unsupported format.
* **Logical Explanation**: The **Compare Inputs** action takes the values from the **Input Value** column (**C:\TestData\Request.json;C:\TestData\ExpectedRequest.json**) and compares both JSON files. The action validates the file content, structure, missing fields, additional fields, and value differences. The comparison result is stored in the **{ComparisonResult}** variable.

<figure><img src="/files/lIpU2vHykVYpyF6Cxugy" alt=""><figcaption></figcaption></figure>

### **Example 2: Comparing an XML File with Static Input**

In this example, we explain how to compare an XML file with static input content.

* **Action**: Compare Inputs
* **Input Value**: C:\Users\Downloads\Test.xml;\<xml\_input>&#x20;
  * The first argument (**C:\Users\Downloads\Test.xml**) specifies the XML file to compare.
  * The second argument (**\<xml\_input>**) specifies the static XML input content.

{% code overflow="wrap" expandable="true" %}

```xml
XML Input
<transactions>
	<transaction>
		<date>2024-10-01</date>
		<amount>100.00</amount>
		<transactionId>TXN12345</transactionId>
	</transaction>
	<transaction>
		<date>2024-09-30</date>
		<amount>150.00</amount>
					<transactionId>TXN12344</transactionId>
				</transaction>
				<transaction>
					<date>2024-02-18</date>
					<amount>1200.00</amount>
					<transactionId>TXN76543</transactionId>
				</transaction>
				<transaction>
					<date>2024-03-01</date>
					<amount>1080.00</amount>
					<transactionId>TXN67890</transactionId>
				</transaction>
			</transactions>
```

{% endcode %}

* **Output Value**: {ComparisonResult}
  * The first output variable (**{ComparisonResult}**) stores the comparison result.
  * If a second output variable is provided, the action returns the status as **True** or **False**:
    * **True**: If the comparison executes successfully.
    * **False**: If the comparison fails due to invalid file path, missing file, or unsupported format.
* **Logical Explanation**: The **Compare Inputs** action takes the values from the **Input Value** column (**C:\Users\Downloads\Test.xml;\<xml\_input>**) and compares the XML file content with the provided static input. The action validates the structure, content, missing tags, and mismatched values. The comparison result is stored in the **{ComparisonResult}** variable.

<figure><img src="/files/rt85qVGBvYfkZSqd5v6f" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Note**: After executing the Test Steps, you can see the result in the Avo Assure Client console.
{% endhint %}

<figure><img src="/files/XeVfWi5znRHr6xPO58fq" alt=""><figcaption></figcaption></figure>

### **Example 3: Comparing Inputs Using Selective Comparison**

In this example, we explain how to compare only the modified content between two inputs using **Selective** comparison.

* **Action**: Compare Inputs
* **Input Value**: {"Name":"John","Age":25,"City":"Mumbai"};{"Name":"John","Age":28,"City":"Mumbai"};Selective
  * The first argument (**{"Name":"John","Age":25,"City":"Mumbai"}**) specifies the original input content.
  * The second argument (**{"Name":"John","Age":28,"City":"Mumbai"}**) specifies the changed input content to compare.
  * The third argument (**Selective**) specifies that the action compares only the modified content instead of the complete structure.
* **Output Value**: {ComparisonResult};{Status}
  * The first output variable (**{ComparisonResult}**) stores the comparison result.
  * The second output variable (**{Status}**) stores the execution result with the following possible values:
    * **True**: If the comparison executes successfully.
    * **False**: If the comparison fails due to invalid input, missing values, or unsupported format.
* **Logical Explanation**: The **Compare Inputs** action takes the values from the **Input Value** column (**{"Name":"John","Age":25,"City":"Mumbai"};{"Name":"John","Age":28,"City":"Mumbai"};Selective**) and compares only the modified content between both inputs. In this example, the action identifies that the **Age** value changes from **25** to **28** while the remaining content stays unchanged. The comparison result is stored in the **{ComparisonResult}** variable as (

  **- {"Name":"John","Age":25,"City":"Mumbai"} ? ^**

  **+ {"Name":"John","Age":28,"City":"Mumbai"} ? ^**

  ).

{% hint style="info" %}
**Note**: Use **Selective** comparison when you want to validate only the changed values between inputs instead of comparing the complete content or structure.
{% endhint %}

<figure><img src="/files/zKNwKFQLAX0Zmot6xEzt" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.avoautomation.com/avo-assure/actions/generic/file-and-folder-operations/compare-inputs.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
