# json_compact_each_row_with_names_and_types

## Description

Positional JSON arrays preceded by arrays of column names and runtime type names. Name matching and type checks use the corresponding JSON settings.

Input and output. Select it with `FORMAT json_compact_each_row_with_names_and_types`. Names ignore ASCII case; use the snake_case name shown here.

The first array contains names, the second contains runtime type names, and subsequent arrays contain values. Name matching and type checks are enabled by their JSON settings.

Header types describe runtime output rather than every original narrow declaration. Align the import target with those types or choose the documented matching/checking options explicitly.

```text
SELECT expressions FORMAT json_compact_each_row_with_names_and_types;
INSERT INTO table [(columns)] [SETTINGS ...] FORMAT json_compact_each_row_with_names_and_types
<data>
```

## Example usage

```sql
SELECT CAST(7 AS Int64) AS id, 'Ada' AS name FORMAT json_compact_each_row_with_names_and_types;
```

```text
["id", "name"]
["Int64", "String"]
[7, "Ada"]
```

## Format settings

Use a statement `SETTINGS` clause; these options are not persisted by `SET`.

| Setting                            | Type     | Default | Meaning                                                                                                                   |
| ---------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `ignore_unknown_fields`            | `Bool`   | `0`     | Skip input keys and header names that match no target column instead of failing.                                          |
| `json_array_of_rows`               | `Bool`   | `0`     | Wrap all output rows in one JSON array.                                                                                   |
| `json_arrays_as_strings`           | `Bool`   | `1`     | Accept JSON arrays in string input columns and retain their JSON text.                                                    |
| `json_bools_as_numbers`            | `Bool`   | `1`     | Accept JSON Boolean input in numeric columns as zero or one.                                                              |
| `json_bools_as_strings`            | `Bool`   | `1`     | Accept JSON Boolean input in string columns as true or false text.                                                        |
| `json_check_types`                 | `Bool`   | `1`     | Compare input metadata or header types with the bound target column types.                                                |
| `json_compact_uneven_rows`         | `Bool`   | `0`     | Give missing positional fields their SQL or native defaults and validate then skip extra fields.                          |
| `json_empty_as_default`            | `Bool`   | `0`     | Give empty JSON string fields their SQL or native type default.                                                           |
| `json_escape_slashes`              | `Bool`   | `1`     | Escape unescaped forward slashes in JSON output strings.                                                                  |
| `json_match_names`                 | `Bool`   | `1`     | Match input header names to target columns ignoring ASCII case; when off, skip the names header and read in target order. |
| `json_named_tuples_as_objects`     | `Bool`   | `1`     | Read and write named Tuple values as objects; otherwise use positional arrays.                                            |
| `json_numbers_as_strings`          | `Bool`   | `1`     | Accept JSON numbers in string input columns and retain their exact spelling.                                              |
| `json_objects_as_strings`          | `Bool`   | `1`     | Accept JSON objects in string input columns and retain their JSON text.                                                   |
| `json_quote_decimals`              | `Bool`   | `0`     | Write fixed-point decimal output values as JSON strings.                                                                  |
| `json_quote_large_floats`          | `Bool`   | `0`     | Write finite Float64 output values as JSON strings.                                                                       |
| `json_quote_large_integers`        | `Bool`   | `0`     | Write integers of at least 64 bits as JSON strings; retained narrow types stay numeric.                                   |
| `json_quote_special_floats`        | `Bool`   | `0`     | Write non-finite floats as inf, -inf, nan, or -nan strings instead of JSON null.                                          |
| `json_strict_escapes`              | `Bool`   | `1`     | Reject invalid JSON escapes; otherwise preserve their literal backslash spelling.                                         |
| `json_tuple_ignore_unknown_fields` | `Bool`   | `0`     | Validate then ignore object members outside a named Tuple declaration.                                                    |
| `json_tuple_missing_as_default`    | `Bool`   | `1`     | Give missing named Tuple members their declared type defaults.                                                            |
| `snappy_mode`                      | `String` | `basic` | Read Snappy client files as basic (Hadoop blocks) or framed (standard streaming format).                                  |
