<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@contract-case/case-definition-dsl](./case-definition-dsl.md) &gt; [interactions](./case-definition-dsl.interactions.md) &gt; [base](./case-definition-dsl.interactions.base.md) &gt; [AnyInteractionDescriptor](./case-definition-dsl.interactions.base.anyinteractiondescriptor.md) &gt; [toJSON](./case-definition-dsl.interactions.base.anyinteractiondescriptor.tojson.md)

## interactions.base.AnyInteractionDescriptor.toJSON() method

Only override this method if you are writing a matcher in a language other than TypeScript.

It exists because the ContractCase matcher format is not legal in all languages that ContractCase supports.

It isn't called by any implementation directly, it's used on the javascript side by `JSON.stringify()`<!-- -->.

Calling it from a wrapper library will return unhelpful results, as JSii can't map all objects that it returns.

WARNING: Do not return a string from this method. You must instead return an object that can be serialised to JSON following the matcher format described in \[Extending ContractCase\](https://case.contract-testing.io/docs/reference/plugin-framework).

**Signature:**

```typescript
toJSON(): unknown;
```

**Returns:**

unknown

An object in the matcher format described \[in the Extending ContractCase documentation\](https://case.contract-testing.io/docs/reference/plugin-framework).
