Expand Up @@ -150,7 +150,7 @@ msgid "" "reference check for container types will be skipped and a circular reference " "will result in a :exc:`RecursionError` (or worse)." msgstr "" "如果 *chech_circular * 設為 false(預設是 ``True``),則針對不同容器型別的循環" "如果 *check_circular * 設為 false(預設是 ``True``),則針對不同容器型別的循環" "參照 (circular reference) 的檢查將會被跳過,若有循環參照則最後將引發 :exc:" "`RecursionError` (或者更糟的錯誤)。" Expand All @@ -162,6 +162,10 @@ msgid "" "*allow_nan* is true, their JavaScript equivalents (``NaN``, ``Infinity``, ``-" "Infinity``) will be used." msgstr "" "如果 *allow_nan* 為 false(預設值:``True``\\ ),則序列化超出嚴格 JSON 規範" "之範圍的 :class:`float` 值 (``nan``, ``inf``, ``-inf``) 會引發 :exc:" "`ValueError`。如果 *allow_nan* 為 true,則將使用它們的 JavaScript 等效項 " "(``NaN``, ``Infinity``, ``-Infinity``)。" #: ../../library/json.rst:168 ../../library/json.rst:452 msgid "" Expand All @@ -172,10 +176,14 @@ msgid "" "indent indents that many spaces per level. If *indent* is a string (such as " "``\"\\t\"``), that string is used to indent each level." msgstr "" "如果 *indent* 是非負整數或字串,則 JSON 陣列元素和物件成員將使用該縮排等級進" "行漂亮列印。縮排等級 0、負數或 ``\"\"`` 只會插入換行符號。``None``\\ (預設" "值)選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如果 " "*indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" #: ../../library/json.rst:175 ../../library/json.rst:459 msgid "Allow strings for *indent* in addition to integers." msgstr "" msgstr "除了整數之外,還允許使用字串進行 *indent*。 " #: ../../library/json.rst:178 ../../library/json.rst:462 msgid "" Expand All @@ -184,10 +192,13 @@ msgid "" "': ')`` otherwise. To get the most compact JSON representation, you should " "specify ``(',', ':')`` to eliminate whitespace." msgstr "" "如果有指定,*separators* 應該是一個 ``(item_separator, key_separator)`` 元" "組。如果 *indent* 為 ``None`` 則預設為 ``(', ', ': ')``,否則預設為 ``(',', " "': ')``。要獲得最緊湊的 JSON 表示形式,你應該指定 ``(',', ':')`` 來消除空格。" #: ../../library/json.rst:183 ../../library/json.rst:467 msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``." msgstr "" msgstr "如果 *indent* 不是 ``None``,則用 ``(',', ': ')`` 當預設值 " #: ../../library/json.rst:186 ../../library/json.rst:470 msgid "" Expand All @@ -196,38 +207,50 @@ msgid "" "version of the object or raise a :exc:`TypeError`. If not specified, :exc:" "`TypeError` is raised." msgstr "" "如果有指定,*default* 應該是一個為無法序列化的物件呼叫的函式。它應該傳回物件" "的 JSON 可編碼版本或引發 :exc:`TypeError`。如果未指定,則會引發 :exc:" "`TypeError`。" #: ../../library/json.rst:191 msgid "" "If *sort_keys* is true (default: ``False``), then the output of dictionaries " "will be sorted by key." msgstr "" "如果 *sort_keys* 為 true(預設值:``False``),則字典的輸出將按鍵排序。" #: ../../library/json.rst:194 msgid "" "To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the :" "meth:`~JSONEncoder.default` method to serialize additional types), specify " "it with the *cls* kwarg; otherwise :class:`JSONEncoder` is used." msgstr "" "若要使用自訂 :class:`JSONEncoder` 子類別(例如覆寫 :meth:`~JSONEncoder." "default` 方法來序列化其他型別的子類別),請使用 *cls* kwarg 指定它;否則使" "用 :class:`JSONEncoder`。" #: ../../library/json.rst:198 ../../library/json.rst:277 msgid "" "All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`." msgstr "" "所有可選參數現在都是\\ :ref:`僅限關鍵字 <keyword-only_parameter>`\\ 了。" #: ../../library/json.rst:203 msgid "" "Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol, so " "trying to serialize multiple objects with repeated calls to :func:`dump` " "using the same *fp* will result in an invalid JSON file." msgstr "" "與 :mod:`pickle` 和 :mod:`marshal` 不同,JSON 不是框架協定,因此嘗試使用相同" "的 *fp* 重複呼叫 :func:`dump` 來序列化多個物件將導致無效的 JSON 檔案。" #: ../../library/json.rst:212 msgid "" "Serialize *obj* to a JSON formatted :class:`str` using this :ref:`conversion " "table <py-to-json-table>`. The arguments have the same meaning as in :func:" "`dump`." msgstr "" "使用此\\ :ref:`轉換表 <json-to-py-table>`\\ 來將 *obj* 序列化為 JSON 格式化 :" "class:`str`。這些引數與 :func:`dump` 中的意義相同。" #: ../../library/json.rst:218 msgid "" Expand All @@ -237,13 +260,20 @@ msgid "" "JSON and then back into a dictionary, the dictionary may not equal the " "original one. That is, ``loads(dumps(x)) != x`` if x has non-string keys." msgstr "" "JSON 鍵/值對中的鍵始終為 :class:`str` 型別。當字典轉換為 JSON 時,字典的所有" "鍵都被強制轉換為字串。因此,如果將字典轉換為 JSON,然後再轉換回字典,則該字典" "可能不等於原始字典。也就是說,如果 x 有非字串鍵,則 ``loads(dumps(x)) != " "x``。" #: ../../library/json.rst:227 msgid "" "Deserialize *fp* (a ``.read()``-supporting :term:`text file` or :term:" "`binary file` containing a JSON document) to a Python object using this :ref:" "`conversion table <json-to-py-table>`." msgstr "" "使用此\\ :ref:`轉換表 <json-to-py-table>`\\ 來將 *fp*\\ (一個支援 ``." "read()``、包含 JSON 文件的\\ :term:`文字檔案 <text file>`\\ 或\\ :term:`二進" "位檔案 <binary file>`\\ )反序列化為 Python 物件。" #: ../../library/json.rst:231 msgid "" Expand All @@ -253,6 +283,10 @@ msgid "" "be used to implement custom decoders (e.g. `JSON-RPC <https://www.jsonrpc." "org>`_ class hinting)." msgstr "" "*object_hook* 是一個可選函式,將使用任何物件文本解碼的結果(一個 :class:" "`dict`\\ )來呼叫它。將使用 *object_hook* 的回傳值而不是 :class:`dict`。此功" "能可用於實作自訂解碼器(例如 `JSON-RPC <https://www.jsonrpc.org>`_ 類別提" "示)。" #: ../../library/json.rst:237 msgid "" Expand All @@ -262,6 +296,10 @@ 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* 是一個可選函式,將使用使用有序對列表解碼的任何物件文本的" "結果來呼叫該函式。將使用 *object_pairs_hook* 的回傳值而不是 :class:`dict`。此" "功能可用於實作自訂解碼器。如果也定義了 *object_hook*,則 *object_pairs_hook* " "優先。" #: ../../library/json.rst:243 ../../library/json.rst:348 msgid "Added support for *object_pairs_hook*." Expand All @@ -274,6 +312,9 @@ msgid "" "This can be used to use another datatype or parser for JSON floats (e.g. :" "class:`decimal.Decimal`)." msgstr "" "如有指定 *parse_float*,將使用要解碼的每個 JSON 浮點數字串進行呼叫。預設情況" "下,這相當於 ``float(num_str)``。這可用於將另一種資料型別或剖析器用於 JSON 浮" "點(例如 :class:`decimal.Decimal`\\ )。" #: ../../library/json.rst:251 ../../library/json.rst:356 msgid "" Expand All @@ -282,24 +323,33 @@ msgid "" "can be used to use another datatype or parser for JSON integers (e.g. :class:" "`float`)." msgstr "" "如有指定 *parse_int*,將使用要解碼的每個 JSON 整數字串進行呼叫。預設情況下," "這相當於 ``int(num_str)``。這可用於對 JSON 整數使用另一種資料型別或剖析器(例" "如 :class:`float`\\ )。" #: ../../library/json.rst:256 msgid "" "The default *parse_int* of :func:`int` now limits the maximum length of the " "integer string via the interpreter's :ref:`integer string conversion length " "limitation <int_max_str_digits>` to help avoid denial of service attacks." msgstr "" ":func:`int` 預設的 *parse_int* 現在對於整數字串有長度上限,上限是直譯器的\\ :" "ref:`整數字串轉換長度限制 <int_max_str_digits>`,這能防止阻斷服務攻擊 " "(denial of service attacks)。" #: ../../library/json.rst:262 ../../library/json.rst:361 msgid "" "*parse_constant*, if specified, will be called with one of the following " "strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to " "raise an exception if invalid JSON numbers are encountered." msgstr "" "如果 *parse_constant* 有值,那麼以 ``'-Infinity'``、``'Infinity'`` 或 " "``'NaN'`` 字串其中之一來呼叫。這也可用於在遇到無效的 JSON 數字時引發一個例" "外。" #: ../../library/json.rst:267 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." msgstr "" msgstr "*parse_constant* 不再以 'null'、 'true'、 'false' 呼叫了。 " #: ../../library/json.rst:270 msgid "" Expand Down