# `Mix.Statifier.Corpus.Json`
[🔗](https://github.com/riddler/statifier-ex/blob/v2.6.0/lib/mix/statifier/corpus/json.ex#L1)

The corpus emitter's JSON encoding, fixed so that two emits of one tree are
byte-identical and a regeneration diff is readable.

An object's keys are written in one fixed order - the order the schemas
under `conformance/schema/` list them in, for every object the corpus files
hold - and a key outside that order after them, sorted. `pretty/1` indents
by two spaces with one array item per line; `compact/1` writes no
whitespace at all. `corpus_file/2` combines the two: the file is pretty and
each case is one compact line, so a changed case is a one-line diff.
Strings are encoded by Elixir's `JSON`.

# `compact`

```elixir
@spec compact(value :: term()) :: String.t()
```

Encodes `value` with no whitespace.

## Examples

    iex> Mix.Statifier.Corpus.Json.compact(%{"suite" => "w3c", "id" => "w3c/test1", "steps" => []})
    ~s|{"id":"w3c/test1","suite":"w3c","steps":[]}|

# `corpus_file`

```elixir
@spec corpus_file(suite :: String.t(), cases :: [map()]) :: String.t()
```

Encodes a corpus file: the suite, then the cases, one compact case per line.

# `pretty`

```elixir
@spec pretty(value :: term()) :: String.t()
```

Encodes `value` with two-space indentation and a trailing newline.

## Examples

    iex> Mix.Statifier.Corpus.Json.pretty(%{"b" => [1], "a" => %{}})
    ~s|{\n  "a": {},\n  "b": [\n    1\n  ]\n}\n|

---

*Consult [api-reference.md](api-reference.md) for complete listing*
