# JsonEditDistanceEvaluator

> **Class** in `langchain_classic`

📖 [View in docs](https://reference.langchain.com/python/langchain-classic/evaluation/parsing/json_distance/JsonEditDistanceEvaluator)

An evaluator that calculates the edit distance between JSON strings.

This evaluator computes a normalized Damerau-Levenshtein distance between two JSON strings
after parsing them and converting them to a canonical format (i.e., whitespace and key order are normalized).
It can be customized with alternative distance and canonicalization functions.

## Signature

```python
JsonEditDistanceEvaluator(
    self,
    string_distance: Callable[[str, str], float] | None = None,
    canonicalize: Callable[[Any], Any] | None = None,
    **_: Any = {},
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `string_distance` | `Callable[[str, str], float] \| None` | No | A callable that computes the distance between two strings. If not provided, a Damerau-Levenshtein distance from the `rapidfuzz` package will be used. (default: `None`) |
| `canonicalize` | `Callable[[Any], Any] \| None` | No | A callable that converts a parsed JSON object into its canonical string form. If not provided, the default behavior is to serialize the JSON with sorted keys and no extra whitespace. (default: `None`) |

## Extends

- `StringEvaluator`

## Constructors

```python
__init__(
    self,
    string_distance: Callable[[str, str], float] | None = None,
    canonicalize: Callable[[Any], Any] | None = None,
    **_: Any = {},
) -> None
```

| Name | Type |
|------|------|
| `string_distance` | `Callable[[str, str], float] \| None` |
| `canonicalize` | `Callable[[Any], Any] \| None` |


## Properties

- `requires_input`
- `requires_reference`
- `evaluation_name`

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/9f232caa7a8fe1ca042a401942d5d90d54ceb1a6/libs/langchain/langchain_classic/evaluation/parsing/json_distance.py#L11)