> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> JSON 포맷 문서

# JSON

| 입력 | 출력 | 별칭 |
| -- | -- | -- |
| ✔  | ✔  |    |

<div id="description">
  ## 설명
</div>

`JSON` 포맷은 JSON 포맷으로 데이터를 읽고 출력합니다.

`JSON` 포맷은 다음을 반환합니다.

| 매개변수                         | 설명                                                                                                                                                                                                                               |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `meta`                       | 컬럼 이름과 타입입니다.                                                                                                                                                                                                                    |
| `data`                       | 데이터 테이블입니다.                                                                                                                                                                                                                      |
| `rows`                       | 출력된 행의 총개수입니다.                                                                                                                                                                                                                   |
| `rows_before_limit_at_least` | LIMIT가 없었다면 출력되었을 행 수의 하한 추정값입니다. 쿼리에 LIMIT가 포함된 경우에만 출력됩니다. 이 추정값은 limit transform 이전의 쿼리 파이프라인에서 처리된 데이터 block을 기준으로 계산되지만, 이후 limit transform에 의해 버려질 수 있습니다. block이 쿼리 파이프라인의 limit transform에 도달하지 못한 경우에는 이 추정에 반영되지 않습니다. |
| `statistics`                 | `elapsed`, `rows_read`, `bytes_read` 등의 통계입니다.                                                                                                                                                                                   |
| `totals`                     | 합계 값입니다(WITH TOTALS 사용 시).                                                                                                                                                                                                       |
| `extremes`                   | 극값입니다(extremes가 1로 설정된 경우).                                                                                                                                                                                                      |

`JSON` 포맷은 JavaScript와 호환됩니다. 이를 보장하기 위해 일부 문자는 추가로 이스케이프됩니다.

* 슬래시 `/`는 `\/`로 이스케이프됩니다.
* 일부 브라우저에서 문제를 일으키는 대체 줄바꿈 문자 `U+2028` 및 `U+2029`는 `\uXXXX`로 이스케이프됩니다.
* ASCII 제어 문자는 이스케이프됩니다. 백스페이스, 폼 피드, 줄 바꿈, 캐리지 리턴, 수평 탭은 각각 `\b`, `\f`, `\n`, `\r`, `\t`로 대체되며, 00-1F 범위의 나머지 바이트도 `\uXXXX` 시퀀스를 사용해 이스케이프됩니다.
* 잘못된 UTF-8 시퀀스는 대체 문자 �로 변경되므로 출력 텍스트는 유효한 UTF-8 시퀀스로만 구성됩니다.

JavaScript와의 호환성을 위해 Int64 및 UInt64 정수는 기본적으로 큰따옴표로 감싸집니다.
따옴표를 제거하려면 구성 매개변수 [`output_format_json_quote_64bit_integers`](/docs/ko/reference/settings/formats#output_format_json_quote_64bit_integers)를 `0`으로 설정할 수 있습니다.

ClickHouse는 [NULL](/docs/ko/reference/syntax)을 지원하며, JSON 출력에서는 `null`로 표시됩니다. 출력에서 `+nan`, `-nan`, `+inf`, `-inf` 값을 허용하려면 [output\_format\_json\_quote\_denormals](/docs/ko/reference/settings/formats#output_format_json_quote_denormals)를 `1`로 설정하십시오.

<div id="example-usage">
  ## 사용 예시
</div>

예시:

```sql theme={null}
SELECT SearchPhrase, count() AS c FROM test.hits GROUP BY SearchPhrase WITH TOTALS ORDER BY c DESC LIMIT 5 FORMAT JSON
```

```json theme={null}
{
        "meta":
        [
                {
                        "name": "num",
                        "type": "Int32"
                },
                {
                        "name": "str",
                        "type": "String"
                },
                {
                        "name": "arr",
                        "type": "Array(UInt8)"
                }
        ],

        "data":
        [
                {
                        "num": 42,
                        "str": "hello",
                        "arr": [0,1]
                },
                {
                        "num": 43,
                        "str": "hello",
                        "arr": [0,1,2]
                },
                {
                        "num": 44,
                        "str": "hello",
                        "arr": [0,1,2,3]
                }
        ],

        "rows": 3,

        "rows_before_limit_at_least": 3,

        "statistics":
        {
                "elapsed": 0.001137687,
                "rows_read": 3,
                "bytes_read": 24
        }
}
```

<div id="format-settings">
  ## 포맷 설정
</div>

JSON 입력 형식에서 [`input_format_json_validate_types_from_metadata`](/docs/ko/reference/settings/formats#input_format_json_validate_types_from_metadata) 설정이 `1`로 지정되면,
입력 데이터 메타데이터의 타입이 테이블에서 해당하는 컬럼의 타입과 비교됩니다.

<div id="see-also">
  ## 관련 항목
</div>

* [JSONEachRow](/docs/ko/reference/formats/JSON/JSONEachRow) 포맷
* [output\_format\_json\_array\_of\_rows](/docs/ko/reference/settings/formats#output_format_json_array_of_rows) 설정
