Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 62 additions & 4 deletions library/json.po
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ msgid ""
"ambiguous. All values in Python are objects. In JSON, an object refers to "
"any data wrapped in curly braces, similar to a Python dictionary."
msgstr ""
"在 Python 中處理 JSON 時,「物件」一詞的意義可能不明確。Python 中的所有值都是"
"物件。在 JSON 中,物件指的是以大括號包住的任何資料,類似於 Python 字典。"

#: ../../library/json.rst:27
msgid ""
Expand Down Expand Up @@ -247,6 +249,20 @@ msgid ""
">>> list(ComplexEncoder().iterencode(2 + 1j))\n"
"['[2.0', ', 1.0', ']']"
msgstr ""
">>> import json\n"
">>> class ComplexEncoder(json.JSONEncoder):\n"
"... def default(self, obj):\n"
"... if isinstance(obj, complex):\n"
"... return [obj.real, obj.imag]\n"
"... # 讓基底類別的預設方法引發 TypeError\n"
"... return super().default(obj)\n"
"...\n"
">>> json.dumps(2 + 1j, cls=ComplexEncoder)\n"
"'[2.0, 1.0]'\n"
">>> ComplexEncoder().encode(2 + 1j)\n"
"'[2.0, 1.0]'\n"
">>> list(ComplexEncoder().iterencode(2 + 1j))\n"
"['[2.0', ', 1.0', ']']"

#: ../../library/json.rst:124
msgid "Using :mod:`!json` from the shell to validate and pretty-print:"
Expand Down Expand Up @@ -332,13 +348,19 @@ msgid ""
"always produces :class:`str` objects, not :class:`bytes` objects, therefore "
"``fp.write()`` must support :class:`str` input."
msgstr ""
"將 *obj* 序列化後寫入的類檔案物件。:mod:`!json` 模組總是產生 :class:`str` "
"物件,而非 :class:`bytes` 物件,因此 ``fp.write()`` 必須支援 :class:`str` "
"輸入。"

#: ../../library/json.rst:178
msgid ""
"If ``True``, keys that are not of a basic type (:class:`str`, :class:`int`, :"
"class:`float`, :class:`bool`, ``None``) will be skipped instead of raising "
"a :exc:`TypeError`. Default ``False``."
msgstr ""
"若為 ``True``,則會略過非基本型別(:class:`str`、:class:`int`、"
":class:`float`、:class:`bool`、``None``)的鍵,而非引發 "
":exc:`TypeError`。預設為 ``False``。"

#: ../../library/json.rst:184
msgid ""
Expand All @@ -348,6 +370,9 @@ msgid ""
"quotation mark, reverse solidus, and the control characters U+0000 through "
"U+001F."
msgstr ""
"若為 ``True``\\ (預設值),則保證輸出中所有輸入的非 ASCII 字元與不可列印字元"
"都會被跳脫。若為 ``False``,則所有字元都會原樣輸出,但必須跳脫的字元除外:"
"引號、反斜線,以及 U+0000 至 U+001F 的控制字元。"

#: ../../library/json.rst:191
msgid ""
Expand Down Expand Up @@ -377,6 +402,9 @@ msgid ""
"overridden, for serializing into custom datatypes. If ``None`` (the "
"default), :class:`!JSONEncoder` is used."
msgstr ""
"若有設定,則為覆寫了 :meth:`~JSONEncoder.default` 方法的自訂 JSON 編碼器,"
"用於序列化為自訂資料型別。若為 ``None``\\ (預設值),則使用 "
":class:`!JSONEncoder`。"

#: ../../library/json.rst:210
msgid ""
Expand All @@ -386,6 +414,9 @@ msgid ""
"level. If zero, negative, or ``\"\"`` (the empty string), only newlines are "
"inserted. If ``None`` (the default), no newlines are inserted."
msgstr ""
"若為正整數或字串,則 JSON 陣列元素和物件成員會以該縮排層級美化輸出。正整數"
"表示每層縮排的空格數;字串(例如 ``\"\\t\"``)則用於每層的縮排。若為零、負數或 "
"``\"\"``\\ (空字串),則只插入換行。若為 ``None``\\ (預設值),則不插入換行。"

#: ../../library/json.rst:220
msgid ""
Expand All @@ -394,21 +425,26 @@ msgid ""
"``(',', ': ')`` otherwise. For the most compact JSON, specify ``(',', ':')`` "
"to eliminate whitespace."
msgstr ""
"一個二元組:``(item_separator, key_separator)``。如為 ``None``\\ (預設值)"
"則 *separators* 被預設為 ``(', ', ': ')``,否則預設為 ``(',', ': ')``。想要獲"
"得最緊湊的 JSON 表示形式,你可以指定 ``(',', ':')`` 來消除空格。"
"一個二元組:``(item_separator, key_separator)``。若 *separators* 為 "
"``None``\\ (預設值),則當 *indent* 為 ``None`` 時使用 ``(', ', ': ')``,"
"否則使用 ``(',', ': ')``。若要獲得最緊湊的 JSON 表示形式,請指定 "
"``(',', ':')`` 以消除空白字元。"

#: ../../library/json.rst:229
msgid ""
"A function that is called for objects that can't otherwise be serialized. It "
"should return a JSON encodable version of the object or raise a :exc:"
"`TypeError`. If ``None`` (the default), :exc:`!TypeError` is raised."
msgstr ""
"遇到無法以其他方式序列化的物件時會被呼叫的函式。它應回傳該物件可供 JSON 編碼"
"的版本,或引發 :exc:`TypeError`。若為 ``None``\\ (預設值),則引發 "
":exc:`!TypeError`。"

#: ../../library/json.rst:236
msgid ""
"If ``True``, dictionaries will be outputted sorted by key. Default ``False``."
msgstr ""
"若為 ``True``,則字典會依鍵排序後輸出。預設為 ``False``。"

#: ../../library/json.rst:242
msgid ""
Expand All @@ -432,7 +468,7 @@ msgstr "除了整數之外,*indent* 還允許使用字串作為輸入。"

#: ../../library/json.rst:253 ../../library/json.rst:536
msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``."
msgstr "如果 *indent* 不是 ``None``,則使用 ``(',', ': ')`` 作為預設值"
msgstr "如果 *indent* 不是 ``None``,則使用 ``(',', ': ')`` 作為預設值。"

#: ../../library/json.rst:256 ../../library/json.rst:346
msgid ""
Expand Down Expand Up @@ -462,13 +498,17 @@ msgid ""
"A ``.read()``-supporting :term:`text file` or :term:`binary file` containing "
"the JSON document to be deserialized."
msgstr ""
"支援 ``.read()`` 且包含待去序列化 JSON 文件的\\ :term:`文字檔案 <text file>`"
"\\ 或\\ :term:`二進位檔案 <binary file>`。"

#: ../../library/json.rst:281
msgid ""
"If set, a custom JSON decoder. Additional keyword arguments to :func:`!load` "
"will be passed to the constructor of *cls*. If ``None`` (the default), :"
"class:`!JSONDecoder` is used."
msgstr ""
"若有設定,則為自訂 JSON 解碼器。傳給 :func:`!load` 的額外關鍵字引數會傳遞給 "
"*cls* 的建構子。若為 ``None``\\ (預設值),則使用 :class:`!JSONDecoder`。"

#: ../../library/json.rst:288
msgid ""
Expand Down Expand Up @@ -528,6 +568,7 @@ msgstr ""
#: ../../library/json.rst:0
msgid "Raises"
msgstr ""
"引發"

#: ../../library/json.rst:332
msgid "When the data being deserialized is not a valid JSON document."
Expand Down Expand Up @@ -700,6 +741,9 @@ msgid ""
"`dict`. This feature can be used to implement custom decoders. If "
"*object_hook* is also defined, the *object_pairs_hook* takes priority."
msgstr ""
"*object_pairs_hook* 是一個可選函式,會以每個 JSON 物件解碼後的有序對串列作為"
"引數來呼叫它。*object_pairs_hook* 的回傳值將用來取代 :class:`dict`。此功能"
"可用於實作自訂解碼器。若也定義了 *object_hook*,則 *object_pairs_hook* 優先。"

#: ../../library/json.rst:416
msgid "Added support for *object_pairs_hook*."
Expand Down Expand Up @@ -1146,6 +1190,16 @@ msgid ""
">>> json.loads('NaN')\n"
"nan"
msgstr ""
">>> # 這兩次呼叫都不會引發例外,但結果不是有效的 JSON\n"
">>> json.dumps(float('-inf'))\n"
"'-Infinity'\n"
">>> json.dumps(float('nan'))\n"
"'NaN'\n"
">>> # 去序列化時亦同\n"
">>> json.loads('-Infinity')\n"
"-inf\n"
">>> json.loads('NaN')\n"
"nan"

#: ../../library/json.rst:682
msgid ""
Expand Down Expand Up @@ -1270,6 +1324,8 @@ msgid ""
"validate and pretty-print JSON objects. The :mod:`!json.tool` submodule "
"implements this interface."
msgstr ""
"可以透過 ``python -m json`` 將 :mod:`!json` 模組當作腳本呼叫,以驗證並美化"
"輸出 JSON 物件。:mod:`!json.tool` 子模組實作了此介面。"

#: ../../library/json.rst:755
msgid ""
Expand Down Expand Up @@ -1309,6 +1365,8 @@ msgid ""
"For backwards compatibility, invoking the CLI as ``python -m json.tool`` "
"remains supported."
msgstr ""
"現在可以透過 ``python -m json`` 直接執行 :mod:`!json` 模組。為了維持向後相容"
"性,仍支援透過 ``python -m json.tool`` 呼叫命令列介面。"

#: ../../library/json.rst:779
msgid "Command-line options"
Expand Down