> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/json/validate.md).

# Validate

Validate your JSON with Json.NET Schema.

Task version: 2.1.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.JSON2>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                  | Description                                                                                                                                                                              |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Json : `Object`       | <p>Json input needs to be of type string or JToken.</p><p><br>Default: <code>-</code><br>Example: <code>{"key":"value"}</code></p>                                                       |
| JsonSchema : `String` | <p>Json Schema to validate to. Uses Newtonsoft JsonSchema</p><p><br>Default: <code>-</code><br>Example: <code>{"type": "object", "properties": {"name": {"type":"string"} } }</code></p> |
| {% endtab %}          |                                                                                                                                                                                          |

{% tab title="Options" %}

| Name                             | Description                                                                                                                                                                                                                                                                                                                                                                                          |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| FailOnInvalidJson : `Boolean`    | <p>A flag to indicate whether invalid JSON should be treated as an error.</p><p>When true, validation failure or parse error is treated as an error (subject to ThrowErrorOnFailure).</p><p>When false, parse/validation errors are returned as a non-successful result with Success=false without going through error handling.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p> |
| ThrowErrorOnFailure : `Boolean`  | <p>If set to true, the task will throw an exception on failure.</p><p>If set to false, the task returns a result with Success = false.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                        |
| ErrorMessageOnFailure : `String` | <p>Optional custom error message used when ThrowErrorOnFailure is true or when returning a failed result.</p><p><br>Default: <code>-</code><br>Example: <code>-</code></p>                                                                                                                                                                                                                           |
| {% endtab %}                     |                                                                                                                                                                                                                                                                                                                                                                                                      |
| {% endtabs %}                    |                                                                                                                                                                                                                                                                                                                                                                                                      |

## Task Result

| Name                               | Description                                                                                   |
| ---------------------------------- | --------------------------------------------------------------------------------------------- |
| Success : `Boolean`                | <p>Operation complete without errors.<br>Example: <code>true</code></p>                       |
| IsValid : `Boolean`                | <p>JSON was valid.<br>Example: <code>true</code></p>                                          |
| Errors : `IList<String>`           | <p>List of errors.<br>Example: <code>{ An error occured..., Another error }</code></p>        |
| Error : `Error`                    | <p>List of errors.<br>Example: <code>{ An error occured..., Another error }</code></p>        |
| Error.Message : `String`           | <p>Error message.<br>Example: <code>Invalid JSON: unexpected character encountered</code></p> |
| Error.AdditionalInfo : `Exception` | <p>Additional error information.<br>Example: <code>System.Exception: Invalid JSON</code></p>  |

## Task Changelog

Changelog for Task Frends.JSON.Validate.

### \[2.1.0] - 2026-10-15

#### Changed

* Added missing examples to the documentation of the result's error properties.

### \[2.0.0] - 2026-08-11

#### Changed

* The task now targets .NET 8.
* Added `ThrowErrorOnFailure` and `ErrorMessageOnFailure` options: you can now choose whether the task throws an exception or returns a failed result when an error occurs, and optionally provide a custom error message.
* Added a `CancellationToken` parameter to support task cancellation.
* The `Result` object now includes an `Error` property with details when the task fails.
* \[Breaking Change] Renamed the `ThrowOnInvalidJson` option to `FailOnInvalidJson` to better reflect its purpose: it controls whether invalid JSON is treated as an error at all, independent of whether that error is thrown or returned (which is controlled by `ThrowErrorOnFailure`). Update any existing task configurations to use `FailOnInvalidJson`.

### \[1.0.0] - 2023-06-15

#### Added

* Initial implementation


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.frends.com/tasks/tasks/json/validate.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
