# Run a program over a document

Run an alchemy program over a JSON document with dmog run, and choose how a table it returns is written.

You have an alchemy program and a JSON document to run it over. `dmog run` takes the program and the document, in that order.

## Run it

Name the program, then the document:

```console
$ dmog run table.alc records.json
"Identifier","Full name","Balance"
"123","Alice","50.25"
"456","Bob","72"
```

Either one can be `-` to read standard input, though not both:

```console
$ cat records.json | dmog run table.alc -
"Identifier","Full name","Balance"
"123","Alice","50.25"
"456","Bob","72"
```

## Choose how a table is written

A program that returns a table leaves its writing to dmog, which writes CSV by default. `--render json` writes an array of objects, one for each row:

```console
$ dmog run --render json table.alc records.json
[{"Identifier":123,"Full name":"Alice","Balance":50.25},{"Identifier":456,"Full name":"Bob","Balance":72}]
```

A program that writes its own text, as [`export.alc`](https://dmog.tabnas.dev/examples/export.alc) does with `csv`, takes no `--render`.

## What to watch for

`run` reads JSON. To run a program over a document in another format, translate it with the program instead, as [Reshape a document while translating it](https://dmog.tabnas.dev/how-to/reshape-with-a-program.html) shows.

Check a program before its first run, so that a mistake in it is reported before the document is read. For how, see [Check and format a program](https://dmog.tabnas.dev/how-to/check-and-format.html).
