{
  "schema": "llmsdocs-editorial-v1",
  "id": "encode",
  "language": "ko",
  "revision": 1,
  "edition": "2026-11-24",
  "kind": "editorial",
  "title": "의도를 보존하며 JSON 쓰기",
  "intro": "문자열 출력과 파일 출력을 먼저 구분하고 유니코드와 유한하지 않은 수의 처리 방식을 정합니다. 이 설명은 Python 3.13.0 기준이며 모든 JSON 구현에 적용되지 않습니다.",
  "html_url": "https://llmsdocs.com/ko/manual/encode",
  "json_url": "https://llmsdocs.com/ko/manual/encode.json",
  "source": {
    "id": "python-json-313",
    "title": "Python 3.13.0: json encoder and decoder",
    "url": "https://github.com/python/cpython/blob/v3.13.0/Doc/library/json.rst",
    "version": "CPython v3.13.0",
    "observed_at": "2026-11-24T04:53:54.630820+00:00",
    "sha256": "6533f6d5be67f903194ba4b92335d079552edb69c4c8fd45d6215de60358dd8e",
    "license": "PSF License Version 2",
    "license_url": "https://github.com/python/cpython/blob/v3.13.0/LICENSE",
    "copyright": "Copyright (c) 2001-2024 Python Software Foundation; All Rights Reserved",
    "snapshot": "/manual-source/json.rst",
    "license_snapshot": "/manual-source/LICENSE.txt"
  },
  "changes": "원문을 주제별로 요약하고 한국어로 번역했습니다. 예제는 자체 작성했습니다.",
  "disclosure": "AI 보조로 구성한 자체 편집 자료입니다. Python 공식 문서나 고객 제출 문서가 아닙니다.",
  "facts": [
    {
      "id": "encode-1",
      "key": "output",
      "value": "str",
      "text": "json.dumps는 JSON 형식의 str을 반환합니다. json.dump는 bytes가 아닌 str을 받는 파일형 객체에 기록합니다.",
      "source_id": "python-json-313",
      "source_lines": "148-163, 218-225"
    },
    {
      "id": "encode-2",
      "key": "ensure_ascii",
      "value": true,
      "text": "ensure_ascii의 기본값은 true이며 비ASCII 문자를 이스케이프합니다. false로 설정하면 해당 문자를 그대로 출력합니다.",
      "source_id": "python-json-313",
      "source_lines": "165-167"
    },
    {
      "id": "encode-3",
      "key": "allow_nan",
      "value": true,
      "text": "allow_nan의 기본값은 true입니다. false로 설정하면 NaN이나 무한대를 JavaScript 표기로 출력하는 대신 ValueError가 발생합니다.",
      "source_id": "python-json-313",
      "source_lines": "173-177"
    },
    {
      "id": "encode-4",
      "key": "sort_keys",
      "value": false,
      "text": "sort_keys의 기본값은 false입니다. true이면 딕셔너리 출력을 키순으로 정렬합니다.",
      "source_id": "python-json-313",
      "source_lines": "202-203"
    }
  ],
  "example": "import json\ntext = json.dumps({\"name\": \"한글\", \"count\": 2},\n                  ensure_ascii=False, allow_nan=False, sort_keys=True)\nprint(text)",
  "editorial_note": "수신 시스템이 JavaScript의 유한하지 않은 값 대신 JSON 수를 요구하면 allow_nan=False를 사용합니다. 이는 문서의 옵션 설명에 근거한 편집 권고입니다."
}
