diff --git a/library/json.po b/library/json.po index b9d14ec55d..2042792d57 100644 --- a/library/json.po +++ b/library/json.po @@ -4,6 +4,7 @@ # # Translators: # Asoul Yang , 2016 +# SkyLull , 2024 msgid "" msgstr "" "Project-Id-Version: Python 3.12\n" @@ -58,8 +59,8 @@ msgid "" ":mod:`json` exposes an API familiar to users of the standard library :mod:" "`marshal` and :mod:`pickle` modules." msgstr "" -":mod:`json` 為標準函式庫 :mod:`marshal` 與 :mod:`pickle` 模組的使用者提供熟悉" -"的 API。" +":mod:`json` 為習慣標準函式庫 :mod:`marshal` 與 :mod:`pickle` 模組的使用者提供" +"熟悉的 API。" #: ../../library/json.rst:29 msgid "Encoding basic Python object hierarchies::" @@ -67,11 +68,11 @@ msgstr "對基本 Python 物件階層進行編碼: ::" #: ../../library/json.rst:48 msgid "Compact encoding::" -msgstr "" +msgstr "改用緊湊型編碼方式: ::" #: ../../library/json.rst:54 msgid "Pretty printing::" -msgstr "美化輸出:" +msgstr "美化輸出: ::" #: ../../library/json.rst:63 msgid "Decoding JSON::" @@ -79,15 +80,15 @@ msgstr "JSON 解碼: ::" #: ../../library/json.rst:75 msgid "Specializing JSON object decoding::" -msgstr "" +msgstr "自訂特殊的 JSON 解碼方式: ::" #: ../../library/json.rst:90 msgid "Extending :class:`JSONEncoder`::" -msgstr "" +msgstr "繼承 :class:`JSONEncoder` 類別並自行擴充額外的編碼方法: ::" #: ../../library/json.rst:108 msgid "Using :mod:`json.tool` from the shell to validate and pretty-print:" -msgstr "" +msgstr "在命令列介面裡使用 :mod:`json.tool` 來驗證 JSON 語法和美化呈現方式:" #: ../../library/json.rst:119 msgid "See :ref:`json-commandline` for detailed documentation." @@ -100,12 +101,18 @@ msgid "" "value) is also a subset of YAML 1.0 and 1.1. This module can thus also be " "used as a YAML serializer." msgstr "" +"JSON 語法是 `YAML `_ 1.2 語法的一種子集合。所以如果使用預" +"設的設定的話(準確來說,使用預設的 *separators* 分隔符設定的話),這個模組的" +"輸出也符合 YAML 1.0 和 1.1 的子集合規範。因此你也可以利用這個模組來當作 YAML " +"的序列化工具(serializer)。" #: ../../library/json.rst:130 msgid "" "This module's encoders and decoders preserve input and output order by " "default. Order is only lost if the underlying containers are unordered." msgstr "" +"這個模組的編、解碼器預設會保存輸入與輸出資料的順序關係,除非一開始的輸入本身" +"就是無序的。" #: ../../library/json.rst:135 msgid "Basic Usage" @@ -117,6 +124,9 @@ msgid "" "supporting :term:`file-like object`) using this :ref:`conversion table `." msgstr "" +"參考這個\\ :ref:`轉換表 `\\ 將 *obj* 序列化為符合 JSON 格式" +"的串流,並寫入到 *fp* (一個支援 ``.write()`` 方法的 :term:`file-like " +"object`)" #: ../../library/json.rst:146 msgid "" @@ -124,12 +134,17 @@ msgid "" "basic type (:class:`str`, :class:`int`, :class:`float`, :class:`bool`, " "``None``) will be skipped instead of raising a :exc:`TypeError`." msgstr "" +"如果 *skipkeys* 被設為 true(預設值:``False``),那麼非基本型別(:class:" +"`str`、:class:`int`、:class:`float`、:class:`bool`、``None``)的 dictionary" +"(字典)鍵值將被略過而不會引發 :exc:`TypeError`。" #: ../../library/json.rst:150 msgid "" "The :mod:`json` module always produces :class:`str` objects, not :class:" "`bytes` objects. Therefore, ``fp.write()`` must support :class:`str` input." msgstr "" +":mod:`json` 模組總是產生 :class:`str` 物件,而非 :class:`bytes` 物件。因此," +"``fp.write()`` 必須支援 :class:`str` 輸入。" #: ../../library/json.rst:154 ../../library/json.rst:433 msgid "" @@ -137,6 +152,8 @@ msgid "" "all incoming non-ASCII characters escaped. If *ensure_ascii* is false, " "these characters will be output as-is." msgstr "" +"如果 *ensure_ascii* 被設為 true(預設值),則輸出時將確保所有輸入的非 ASCII " +"字元都會被轉義。若 *ensure_ascii* 為 false,則這些字元將照原樣輸出。" #: ../../library/json.rst:158 msgid "" @@ -145,8 +162,8 @@ msgid "" "will result in a :exc:`RecursionError` (or worse)." msgstr "" "如果 *check_circular* 設為 false(預設是 ``True``),則針對不同容器型別的循環" -"參照 (circular reference) 的檢查將會被跳過,若有循環參照則最後將引發 :exc:" -"`RecursionError` (或者更糟的錯誤)。" +"參照 (circular reference) 檢查將會被跳過,若有循環參照則最後將引發 :exc:" +"`RecursionError` (或其他更糟的錯誤)。" #: ../../library/json.rst:162 msgid "" @@ -156,9 +173,9 @@ 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 等效項 " +"如果 *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 @@ -171,13 +188,13 @@ msgid "" "``\"\\t\"``), that string is used to indent each level." msgstr "" "如果 *indent* 是非負整數或字串,則 JSON 陣列元素和物件成員將使用該縮排等級進" -"行漂亮列印。縮排等級 0、負數或 ``\"\"`` 只會插入換行符號。``None``\\ (預設" -"值)選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如果 " -"*indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" +"行格式美化。縮排等級 0、負數或 ``\"\"`` 只會插入換行符號。``None``\\ (預設" +"值)等於是選擇最緊湊的表示法。使用正整數縮排可以在每層縮排數量相同的空格。如" +"果 *indent* 是一個字串(例如 ``\"\\t\"``\\ ),則該字串用於縮排每個層級。" #: ../../library/json.rst:175 ../../library/json.rst:459 msgid "Allow strings for *indent* in addition to integers." -msgstr "除了整數之外,還允許使用字串進行 *indent*。" +msgstr "除了整數之外,*indent* 還允許使用字串作為輸入。" #: ../../library/json.rst:178 ../../library/json.rst:462 msgid "" @@ -186,13 +203,14 @@ msgid "" "': ')`` otherwise. To get the most compact JSON representation, you should " "specify ``(',', ':')`` to eliminate whitespace." msgstr "" -"如果有指定,*separators* 應該是一個 ``(item_separator, key_separator)`` 元" -"組。如果 *indent* 為 ``None`` 則預設為 ``(', ', ': ')``,否則預設為 ``(',', " -"': ')``。要獲得最緊湊的 JSON 表示形式,你應該指定 ``(',', ':')`` 來消除空格。" +"如果有指定本引數內容,*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 "如果 *indent* 不是 ``None``,則用 ``(',', ': ')`` 當預設值" +msgstr "如果 *indent* 不是 ``None``,則使用 ``(',', ': ')`` 作為預設值" #: ../../library/json.rst:186 ../../library/json.rst:470 msgid "" @@ -201,16 +219,16 @@ msgid "" "version of the object or raise a :exc:`TypeError`. If not specified, :exc:" "`TypeError` is raised." msgstr "" -"如果有指定,*default* 應該是一個為無法序列化的物件呼叫的函式。它應該傳回物件" -"的 JSON 可編碼版本或引發 :exc:`TypeError`。如果未指定,則會引發 :exc:" -"`TypeError`。" +"如果有指定本參數,*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``),則字典的輸出將按鍵排序。" +"如果 *sort_keys* 為 true(預設值:``False``),則字典的輸出將按鍵值排序。" #: ../../library/json.rst:194 msgid "" @@ -218,24 +236,27 @@ msgid "" "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`。" +"若要使用繼承自 :class:`JSONEncoder` 的自訂子類別(例如覆寫 :meth:" +"`~JSONEncoder.default` 方法來序列化其他型別的一個子類別物件),請使用關鍵字引" +"數 *cls* 指定該類別物件;否則預設使用 :class:`JSONEncoder`。" #: ../../library/json.rst:198 ../../library/json.rst:277 msgid "" "All optional parameters are now :ref:`keyword-only `." msgstr "" -"所有可選參數現在都是\\ :ref:`僅限關鍵字 `\\ 了。" +"所有可選參數現在都是\\ :ref:`僅限關鍵字 `\\ 參數了。" +# SkyLull: 我想這裡的 "framed protocol" 指的是 +# https://peps.python.org/pep-3154/#framing #: ../../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 檔案。" +"與 :mod:`pickle` 和 :mod:`marshal` 不同,JSON 不具有二進位分框(binary " +"framed)的協定,因此嘗試重複呼叫 :func:`dump` 來序列化多個物件到同一個 *fp* " +"裡將導致無效的 JSON 檔案。" #: ../../library/json.rst:212 msgid "" @@ -243,8 +264,8 @@ msgid "" "table `. The arguments have the same meaning as in :func:" "`dump`." msgstr "" -"使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格式化 :" -"class:`str`。這些引數與 :func:`dump` 中的意義相同。" +"使用此\\ :ref:`轉換表 `\\ 來將 *obj* 序列化為 JSON 格式 :" +"class:`str`。這個引數的作用與 :func:`dump` 中的同名引數意義相同。" #: ../../library/json.rst:218 msgid "" @@ -254,10 +275,10 @@ 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``。" +"JSON 鍵/值對中的鍵始終為 :class:`str` 型別。當字典被轉換為 JSON 時,字典的所" +"有鍵值資料型別都會被強制轉換為字串。因此,如果將字典先轉換為 JSON 格式然後再" +"轉換回字典,則該字典可能不等於原始字典。也就是說,如果字典 x 含有非字串鍵值," +"則 ``loads(dumps(x)) != x``。" #: ../../library/json.rst:227 msgid "" @@ -267,7 +288,7 @@ msgid "" msgstr "" "使用此\\ :ref:`轉換表 `\\ 來將 *fp*\\ (一個支援 ``." "read()``、包含 JSON 文件的\\ :term:`文字檔案 `\\ 或\\ :term:`二進" -"位檔案 `\\ )反序列化為 Python 物件。" +"位檔案 `\\ )去序列化為 Python 物件。" #: ../../library/json.rst:231 msgid "" @@ -277,10 +298,10 @@ msgid "" "be used to implement custom decoders (e.g. `JSON-RPC `_ class hinting)." msgstr "" -"*object_hook* 是一個可選函式,將使用任何物件文本解碼的結果(一個 :class:" -"`dict`\\ )來呼叫它。將使用 *object_hook* 的回傳值而不是 :class:`dict`。此功" -"能可用於實作自訂解碼器(例如 `JSON-RPC `_ 類別提" -"示)。" +"*object_hook* 是一個可選引數,其接受一個函式作為輸入。原始的字串解碼結果(一" +"個 :class:`dict`\\ )將被傳入這個函式、並使用 *object_hook* 的回傳值來取代原" +"先的 :class:`dict` 輸出。此功能可用於實作自訂解碼器(例如 `JSON-RPC `_ 類別提示)。" #: ../../library/json.rst:237 msgid "" @@ -290,10 +311,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* " -"優先。" +"*object_pairs_hook* 是一個可選引數,其接受一個函式作為輸入。原始的有序對串列" +"(ordered list of pairs)解碼結果將被傳入這個函式、並使用 " +"*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*." @@ -306,9 +327,10 @@ 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`\\ )。" +"如有給定 *parse_float* 的話,每個要被解碼的 JSON 浮點數字串都會改用這個參數給" +"定的函式來進行解碼。預設情況的浮點數剖析器等效於 ``float(num_str)``。這個參數" +"可用於將 JSON 中的浮點數解碼或剖析為另一種資料型別(例如 :class:`decimal." +"Decimal`\\ )。" #: ../../library/json.rst:251 ../../library/json.rst:356 msgid "" @@ -317,9 +339,9 @@ 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`\\ )。" +"如有給定 *parse_int* 的話,每個要被解碼的 JSON 整數字串都會改用這個參數給定的" +"函式來進行解碼。預設情況的整數剖析器等效於 ``int(num_str)``。這個參數可用於" +"將 JSON 中的整數解碼或剖析為另一種資料型別(例如 :class:`float`\\ )。" #: ../../library/json.rst:256 msgid "" @@ -327,9 +349,9 @@ msgid "" "integer string via the interpreter's :ref:`integer string conversion length " "limitation ` to help avoid denial of service attacks." msgstr "" -":func:`int` 預設的 *parse_int* 現在對於整數字串有長度上限,上限是直譯器的\\ :" -"ref:`整數字串轉換長度限制 `,這能防止阻斷服務攻擊 " -"(denial of service attacks)。" +"預設 *parse_int* 使用的 :func:`int` 函式現在有限制整數字串的長度上限了,限制" +"由直譯器的\\ :ref:`整數字串轉換長度限制 `\\ 機制來達成," +"這能防止阻斷服務攻擊 (Denial of Service attacks)。" #: ../../library/json.rst:262 ../../library/json.rst:361 msgid "" @@ -337,13 +359,14 @@ msgid "" "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 數字時引發一個例" -"外。" +"如有給定 *parse_constant* 的話,在解碼時若遭遇字串 ``'-Infinity'``、" +"``'Infinity'`` 或 ``'NaN'`` 其中之一則會改用這個參數給定的函式來進行解碼。這" +"也可用於使解碼過程中遇到無效的 JSON 數字時引發一個例外。" #: ../../library/json.rst:267 msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore." -msgstr "*parse_constant* 不再以 'null'、 'true'、 'false' 呼叫了。" +msgstr "" +"遭遇 'null'、'true' 或 'false' 時不再以 *parse_constant* 給定的函式來處理了。" #: ../../library/json.rst:270 msgid "" @@ -351,6 +374,9 @@ msgid "" "kwarg; otherwise :class:`JSONDecoder` is used. Additional keyword arguments " "will be passed to the constructor of the class." msgstr "" +"若想要使用自訂的 :class:`JSONDecoder` 子類別物件,請以 ``cls`` 關鍵字引數指定" +"之,否則將使用預設的 :class:`JSONDecoder`。其他未使用到的關鍵字引數將繼續傳入" +"給 JSONDecoder 的建構函式使用。" #: ../../library/json.rst:274 ../../library/json.rst:292 #: ../../library/json.rst:371 @@ -358,12 +384,16 @@ msgid "" "If the data being deserialized is not a valid JSON document, a :exc:" "`JSONDecodeError` will be raised." msgstr "" +"如果被去序列化(deserialized)的資料不符合 JSON 格式,將會引發 :exc:" +"`JSONDecodeError` 例外。" #: ../../library/json.rst:280 msgid "" "*fp* can now be a :term:`binary file`. The input encoding should be UTF-8, " "UTF-16 or UTF-32." msgstr "" +"現在,*fp* 可以是一個\\ :term:`二進位檔案 `,前提是其編碼格式為 " +"UTF-8、UTF-16 或 UTF-32。" #: ../../library/json.rst:286 msgid "" @@ -371,32 +401,37 @@ msgid "" "instance containing a JSON document) to a Python object using this :ref:" "`conversion table `." msgstr "" +"使用\\ :ref:`轉換表 `\\ 將 *s* (一個含有 JSON 文件的 :" +"class:`str`、:class:`bytes` 或 :class:`bytearray` 的實例(instance))去序列" +"化(deserialize)為一個 Python 物件" #: ../../library/json.rst:290 msgid "The other arguments have the same meaning as in :func:`load`." -msgstr "" +msgstr "其餘引數的使用方式與意義和 :func:`load` 的相同。" #: ../../library/json.rst:295 msgid "" "*s* can now be of type :class:`bytes` or :class:`bytearray`. The input " "encoding should be UTF-8, UTF-16 or UTF-32." msgstr "" +"現在,*s* 可以是一個二進位檔案如 :class:`bytes` 或 :class:`bytearray`,前提是" +"其編碼格式為 UTF-8、UTF-16 或 UTF-32。" #: ../../library/json.rst:299 msgid "The keyword argument *encoding* has been removed." -msgstr "關鍵字引數 *encoding* 已經被刪除。" +msgstr "刪除關鍵字引數 *encoding*。" #: ../../library/json.rst:304 msgid "Encoders and Decoders" -msgstr "" +msgstr "編碼器與解碼器" #: ../../library/json.rst:308 msgid "Simple JSON decoder." -msgstr "" +msgstr "簡易 JSON 解碼器" #: ../../library/json.rst:310 msgid "Performs the following translations in decoding by default:" -msgstr "" +msgstr "預設將執行下列資料型別轉換:" #: ../../library/json.rst:315 ../../library/json.rst:404 msgid "JSON" @@ -432,7 +467,7 @@ msgstr "str" #: ../../library/json.rst:323 msgid "number (int)" -msgstr "number (int)" +msgstr "number (整數)" #: ../../library/json.rst:323 msgid "int" @@ -440,7 +475,7 @@ msgstr "int" #: ../../library/json.rst:325 msgid "number (real)" -msgstr "" +msgstr "number (實數)" #: ../../library/json.rst:325 msgid "float" @@ -475,6 +510,8 @@ msgid "" "It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as their " "corresponding ``float`` values, which is outside the JSON spec." msgstr "" +"雖然 ``NaN``、``Infinity`` 和 ``-Infinity`` 並不符合 JSON 規範,但解碼器依然" +"能正確地將其轉換到相應的 Python ``float`` 值。" #: ../../library/json.rst:337 msgid "" @@ -483,6 +520,10 @@ msgid "" "class:`dict`. This can be used to provide custom deserializations (e.g. to " "support `JSON-RPC `_ class hinting)." msgstr "" +"*object_hook* 是一個可選引數,其接受一個函式作為輸入。原始的字串解碼結果(一" +"個 :class:`dict`\\ )將被傳入這個函式、並使用 *object_hook* 的回傳值來取代原" +"先的 dict 輸出。此功能可用於實作自訂的去序列化功能(例如 `JSON-RPC `_ 類別提示)。" #: ../../library/json.rst:342 msgid "" @@ -492,6 +533,10 @@ msgid "" "can be used to implement custom decoders. If *object_hook* is also defined, " "the *object_pairs_hook* takes priority." msgstr "" +"*object_pairs_hook* 是一個可選引數,其接受一個函式作為輸入。原始的有序對串列" +"(ordered list of pairs)解碼結果將被傳入這個函式、並使用 " +"*object_pairs_hook* 的回傳值來取代原先的 :class:`dict` 輸出。此功能可用於實作" +"自訂解碼器。如果也同時給定了 *object_hook*,則 *object_pairs_hook* 優先。" #: ../../library/json.rst:366 msgid "" @@ -500,22 +545,27 @@ msgid "" "with character codes in the 0--31 range, including ``'\\t'`` (tab), " "``'\\n'``, ``'\\r'`` and ``'\\0'``." msgstr "" +"如果 *strict* 被設為 false(預設值為 ``True``),那麼字串中將允許控制字元。此" +"語境中的控制字元指的是 ASCII 字元編碼在 0~31 範圍內的字元,包括 ``'\\t'``" +"(tab)、``'\\n'``、``'\\r'`` 和 ``'\\0'``。" #: ../../library/json.rst:374 ../../library/json.rst:475 msgid "All parameters are now :ref:`keyword-only `." msgstr "" +"所有參數現在都是\\ :ref:`僅限關鍵字參數 `\\ 了。" #: ../../library/json.rst:379 msgid "" "Return the Python representation of *s* (a :class:`str` instance containing " "a JSON document)." msgstr "" +"回傳用 Python 型式表達的 *s* (一個含有 JSON 文件的 :class:`str` 實例)。" #: ../../library/json.rst:382 msgid "" ":exc:`JSONDecodeError` will be raised if the given JSON document is not " "valid." -msgstr "" +msgstr "若給定的輸入不符合 JSON 格式會引發 :exc:`JSONDecodeError` 例外。" #: ../../library/json.rst:387 msgid "" @@ -523,20 +573,22 @@ msgid "" "document) and return a 2-tuple of the Python representation and the index in " "*s* where the document ended." msgstr "" +"將 *s* (一個開頭部分含有合格 JSON 文件的 :class:`str`) 解碼,並將 JSON 文件" +"結束點的索引值(index)和解碼結果合併為一個二元組(2-tuple)後回傳。" #: ../../library/json.rst:391 msgid "" "This can be used to decode a JSON document from a string that may have " "extraneous data at the end." -msgstr "" +msgstr "這個方法可以用來解碼尾段可能帶有 JSON 以外資料的文字。" #: ../../library/json.rst:397 msgid "Extensible JSON encoder for Python data structures." -msgstr "" +msgstr "可擴充的 Python 資料結構 JSON 編碼器。" #: ../../library/json.rst:399 msgid "Supports the following objects and types by default:" -msgstr "" +msgstr "預設可支援下列物件及型別:" #: ../../library/json.rst:408 msgid "list, tuple" @@ -545,14 +597,17 @@ msgstr "list, tuple" #: ../../library/json.rst:412 msgid "int, float, int- & float-derived Enums" msgstr "" +"int、float 或可作為整數或浮點數運算的衍生列舉(int- or float-derived Enums)" #: ../../library/json.rst:412 msgid "number" -msgstr "" +msgstr "number" #: ../../library/json.rst:421 msgid "Added support for int- and float-derived Enum classes." msgstr "" +"增加對整數(int)、浮點數(float)或可作為整數或浮點數運算的衍生列舉(int- " +"or float-derived Enums)類別的支援性。" #: ../../library/json.rst:424 msgid "" @@ -561,6 +616,9 @@ msgid "" "serializable object for ``o`` if possible, otherwise it should call the " "superclass implementation (to raise :exc:`TypeError`)." msgstr "" +"若要擴充此功能來識別其他物件,請繼承並實作一個 :meth:`~JSONEncoder.default` " +"方法。此方法應回傳一個可序列化的 ``o`` 物件,否則此方法應呼叫父類別的 " +"JSONEncoder.default 方法(以引發 :exc:`TypeError` 例外)。" #: ../../library/json.rst:429 msgid "" @@ -568,6 +626,9 @@ msgid "" "trying to encode keys that are not :class:`str`, :class:`int`, :class:" "`float` or ``None``. If *skipkeys* is true, such items are simply skipped." msgstr "" +"若 *skipkeys* 為 false(預設值),則當在編碼不是 :class:`str`、:class:" +"`int`、:class:`float` 或 ``None`` 的鍵值時,將引發 :exc:`TypeError`。如果 " +"*skipkeys* 為 true,這些項目將直接被跳過。" #: ../../library/json.rst:437 msgid "" @@ -576,6 +637,9 @@ msgid "" "prevent an infinite recursion (which would cause a :exc:`RecursionError`). " "Otherwise, no such check takes place." msgstr "" +"如果 *check_circular* 為 true(預設值),則會在編碼期間檢查串列(list)、字典" +"(dict)和自訂編碼物件的循環參照,以防止無限遞迴(一個會導致 :exc:" +"`RecursionError` 例外的問題)。否則不會進行此類檢查。" #: ../../library/json.rst:442 msgid "" @@ -584,6 +648,10 @@ msgid "" "compliant, but is consistent with most JavaScript based encoders and " "decoders. Otherwise, it will be a :exc:`ValueError` to encode such floats." msgstr "" +"如果 *allow_nan* 為 true(預設值),則 ``NaN``、``Infinity`` 和 ``-" +"Infinity`` 將按照原樣進行編碼。請記得此行為不符合標準 JSON 規範,但的確與大多" +"數基於 JavaScript 的編碼器和解碼器一致。否則若設為 false,嘗試對這些浮點數進" +"行編碼將引發 :exc:`ValueError` 例外。" #: ../../library/json.rst:448 msgid "" @@ -591,6 +659,9 @@ msgid "" "will be sorted by key; this is useful for regression tests to ensure that " "JSON serializations can be compared on a day-to-day basis." msgstr "" +"如果 *sort_keys* 為 true(預設值:``False``),則 dictionary(字典)的輸出將" +"按鍵值排序。這項功能可確保 JSON 序列化的結果能被互相比較,能讓日常的回歸測試" +"檢查變得方便一些。" #: ../../library/json.rst:481 msgid "" @@ -598,24 +669,30 @@ msgid "" "object for *o*, or calls the base implementation (to raise a :exc:" "`TypeError`)." msgstr "" +"在任意一個子類別裡實作這個方法時須讓其回傳一個可序列化的物件 *o* ,或呼叫原始" +"的實作以引發 :exc:`TypeError` 例外。" #: ../../library/json.rst:485 msgid "" "For example, to support arbitrary iterators, you could implement :meth:" "`~JSONEncoder.default` like this::" msgstr "" +"舉例來說,想要讓編碼器支援任意疊代器(iterator),你可以實作這樣子的 :meth:" +"`~JSONEncoder.default`: ::" #: ../../library/json.rst:501 msgid "" "Return a JSON string representation of a Python data structure, *o*. For " "example::" -msgstr "" +msgstr "回傳一個 Python 資料結構物件 *o* 的 JSON 的字串表示。例如: ::" #: ../../library/json.rst:510 msgid "" "Encode the given object, *o*, and yield each string representation as " "available. For example::" msgstr "" +"將物件 *o* 編碼,並將結果統整為一個能依序產生(yield)各結果字串的物件。如下" +"例: ::" #: ../../library/json.rst:518 msgid "Exceptions" @@ -623,31 +700,31 @@ msgstr "例外" #: ../../library/json.rst:522 msgid "Subclass of :exc:`ValueError` with the following additional attributes:" -msgstr "" +msgstr ":exc:`ValueError` 的子類別具有下列額外屬性:" #: ../../library/json.rst:526 msgid "The unformatted error message." -msgstr "" +msgstr "未受格式化的錯誤訊息。" #: ../../library/json.rst:530 msgid "The JSON document being parsed." -msgstr "" +msgstr "正在被剖析的 JSON 文件。" #: ../../library/json.rst:534 msgid "The start index of *doc* where parsing failed." -msgstr "" +msgstr "*doc* 剖析失敗處的起始點的索引值。" #: ../../library/json.rst:538 msgid "The line corresponding to *pos*." -msgstr "" +msgstr "*pos* 所在的列(line)數。" #: ../../library/json.rst:542 msgid "The column corresponding to *pos*." -msgstr "" +msgstr "*pos* 所在的行(column)數。" #: ../../library/json.rst:548 msgid "Standard Compliance and Interoperability" -msgstr "" +msgstr "合規性與互通性(Interoperability)" #: ../../library/json.rst:550 msgid "" @@ -657,22 +734,28 @@ msgid "" "simplicity, :class:`JSONEncoder` and :class:`JSONDecoder` subclasses, and " "parameters other than those explicitly mentioned, are not considered." msgstr "" +"JSON 格式是由 :rfc:`7159` 和 `ECMA-404 `_ 規範的。本節詳細說明了本模" +"組對 RFC 的遵循程度。簡單起見,:class:`JSONEncoder` 和 :class:`JSONDecoder` " +"子類別以及未明確提及的參數將不予討論。" #: ../../library/json.rst:556 msgid "" "This module does not comply with the RFC in a strict fashion, implementing " "some extensions that are valid JavaScript but not valid JSON. In particular:" msgstr "" +"這個模組的部份實作並未非常嚴格地遵循 RFC 規範。準確來說,下列實際實作符合 " +"JavaScript 語法格式,但並不符合 JSON 格式:" #: ../../library/json.rst:559 msgid "Infinite and NaN number values are accepted and output;" -msgstr "" +msgstr "無限(Infinite)和非數字(NaN)值會被接受。" #: ../../library/json.rst:560 msgid "" "Repeated names within an object are accepted, and only the value of the last " "name-value pair is used." -msgstr "" +msgstr "同一個物件內可以有重複的名稱,但只有最後一個同名物件是有效的。" #: ../../library/json.rst:563 msgid "" @@ -680,10 +763,12 @@ msgid "" "not RFC-compliant, this module's deserializer is technically RFC-compliant " "under default settings." msgstr "" +"不過 RFC 准許遵循 RFC 的剖析器接受不合規的文字輸入,所以技術上來說若以預設設" +"定運作,本模組的去序列化器(deserializer)是符合 RFC 規範的。" #: ../../library/json.rst:568 msgid "Character Encodings" -msgstr "" +msgstr "字元編碼格式" #: ../../library/json.rst:570 msgid "" @@ -691,6 +776,8 @@ msgid "" "UTF-32, with UTF-8 being the recommended default for maximum " "interoperability." msgstr "" +"RFC 要求 JSON 必須以 UTF-8、UTF-16 或 UTF-32 格式編碼。並推薦以 UTF-8 編碼以" +"達成最佳的互通性。" #: ../../library/json.rst:573 msgid "" @@ -698,6 +785,8 @@ msgid "" "*ensure_ascii=True* by default, thus escaping the output so that the " "resulting strings only contain ASCII characters." msgstr "" +"RFC 准許但並不強制編碼器的 *ensure_ascii=True* 行為是預設值,但本模組依然實作" +"了此一選項作為預設,因此本模組預設會轉義所有非 ASCII 字元。" #: ../../library/json.rst:577 msgid "" @@ -706,6 +795,8 @@ msgid "" "`, and thus does not otherwise directly address the issue of character " "encodings." msgstr "" +"除了 *ensure_ascii* 選項參數之外,本模組嚴格遵循 Python 物件與 :class:" +"`Unicode strings ` 之間的轉換規範,因此並不另外處理字元編碼的問題。" #: ../../library/json.rst:582 msgid "" @@ -715,6 +806,10 @@ msgid "" "in their input. This module's deserializer raises a :exc:`ValueError` when " "an initial BOM is present." msgstr "" +"RFC 禁止在文件的開頭加上端序記號(Byte Order Mark),因此本模組的序列化器" +"(serializer)也不會在輸出中加入端序記號。RFC 允許但不強制 JSON 去序列化器" +"(deserializer)忽略文件初始的端序記號,因此本模組的去序列化器將在遭遇位於文" +"件開頭的端序記號時引發 :exc:`ValueError` 例外。" #: ../../library/json.rst:588 msgid "" @@ -724,10 +819,14 @@ msgid "" "By default, this module accepts and outputs (when present in the original :" "class:`str`) code points for such sequences." msgstr "" +"RFC 並未明確禁止 JSON 文件包含無法對應有效 Unicode 字元的位元組序列(例如未配" +"對的 UTF-16 代理對(surrogate pairs)),但這個特性的確可能會引起相容性問題。" +"預設情況下,當原始輸入的 :class:`str` 中存在此類序列時,該模組將接受並輸出這" +"些序列的編碼位置(code points)。" #: ../../library/json.rst:596 msgid "Infinite and NaN Number Values" -msgstr "" +msgstr "正負無限與非數值" #: ../../library/json.rst:598 msgid "" @@ -735,6 +834,8 @@ msgid "" "Despite that, by default, this module accepts and outputs ``Infinity``, ``-" "Infinity``, and ``NaN`` as if they were valid JSON number literal values::" msgstr "" +"RFC 不允許表現無限大或非數值(NaN)。但預設情況下,這個模組仍接受並輸出 " +"``Infinity``、``-Infinity`` 和 ``NaN``,如同它們是有效的 JSON 數值字面值: ::" #: ../../library/json.rst:613 msgid "" @@ -742,10 +843,12 @@ msgid "" "behavior. In the deserializer, the *parse_constant* parameter can be used " "to alter this behavior." msgstr "" +"在序列化器中,*allow_nan* 參數可以改變這個行為。在去序列化器中," +"*parse_constant* 參數可以改變這個行為。" #: ../../library/json.rst:619 msgid "Repeated Names Within an Object" -msgstr "" +msgstr "物件內重複的名稱" #: ../../library/json.rst:621 msgid "" @@ -754,14 +857,17 @@ msgid "" "default, this module does not raise an exception; instead, it ignores all " "but the last name-value pair for a given name::" msgstr "" +"RFC 規範僅表明 JSON 物件中的名字應該是唯一的,但沒有強制要求如何處理重複的名" +"字。預設情況下,本模組不會因此引發例外;相反的,它會忽略該名字的所有重複鍵值" +"對,並只保留最後一個: ::" #: ../../library/json.rst:630 msgid "The *object_pairs_hook* parameter can be used to alter this behavior." -msgstr "*object_parts_hook* 參數可以被使用來改變此行為。" +msgstr "*object_parts_hook* 參數可以改變這個行為。" #: ../../library/json.rst:634 msgid "Top-level Non-Object, Non-Array Values" -msgstr "" +msgstr "位於頂層的非物件及非列表值" #: ../../library/json.rst:636 msgid "" @@ -772,42 +878,48 @@ msgid "" "this module does not and has never implemented that restriction in either " "its serializer or its deserializer." msgstr "" +"由已廢棄的 :rfc:`4627` 所規範的舊版 JSON 要求 JSON 文字的頂層值必須是 JSON 物" +"件或陣列(Python :class:`dict` 或 :class:`list`),而且不能是 JSON 的 null、" +"boolean、數字或字串值。 :rfc:`7159` 移除了這個限制,而本模組的序列化器或去串" +"列化器中未曾實施過該限制。" #: ../../library/json.rst:643 msgid "" "Regardless, for maximum interoperability, you may wish to voluntarily adhere " "to the restriction yourself." -msgstr "" +msgstr "如果想要最大限度地保留互通性,你可能還是會想要自行施加這個限制。" #: ../../library/json.rst:648 msgid "Implementation Limitations" -msgstr "" +msgstr "實作限制" #: ../../library/json.rst:650 msgid "Some JSON deserializer implementations may set limits on:" -msgstr "" +msgstr "某些 JSON 去序列化器的實作可能會造成下列限制:" #: ../../library/json.rst:652 msgid "the size of accepted JSON texts" -msgstr "" +msgstr "JSON 文件長度上限" #: ../../library/json.rst:653 msgid "the maximum level of nesting of JSON objects and arrays" -msgstr "" +msgstr "JSON 物件或陣列的最大巢狀層數(level of nesting)限制" #: ../../library/json.rst:654 msgid "the range and precision of JSON numbers" -msgstr "" +msgstr "數字的精準度或範圍" #: ../../library/json.rst:655 msgid "the content and maximum length of JSON strings" -msgstr "" +msgstr "JSON 字串長度上限" #: ../../library/json.rst:657 msgid "" "This module does not impose any such limits beyond those of the relevant " "Python datatypes themselves or the Python interpreter itself." msgstr "" +"本模組除了 Python 資料型態本身或 Python 直譯器本身的限制以外,不會設定任何此" +"類限制。" #: ../../library/json.rst:660 msgid "" @@ -819,6 +931,10 @@ msgid "" "magnitude, or when serializing instances of \"exotic\" numerical types such " "as :class:`decimal.Decimal`." msgstr "" +"將資料序列化為 JSON 時,要注意可能會使用該 JSON 輸出的應用程式中的相關限制。" +"特別要注意的是,JSON 數字常會被去序列化為 IEEE 754 雙精度浮點數(double),並" +"因而受到其表示範圍和精度限制的影響。這在序列化極大的 Python :class:`int` 數" +"值、或是序列化特殊數字型別的實例時(例如 :class:`decimal.Decimal`)尤其重要。" #: ../../library/json.rst:673 msgid "Command Line Interface" @@ -833,18 +949,23 @@ msgid "" "The :mod:`json.tool` module provides a simple command line interface to " "validate and pretty-print JSON objects." msgstr "" +":mod:`json.tool` 模組提供了一個簡易的命令列界面以供校驗與美化呈現 JSON 物件。" #: ../../library/json.rst:685 msgid "" "If the optional ``infile`` and ``outfile`` arguments are not specified, :" "data:`sys.stdin` and :data:`sys.stdout` will be used respectively:" msgstr "" +"如果沒有指定可選引數 ``infile`` 和 ``outfile`` ,則 :data:`sys.stdin` 和 :" +"data:`sys.stdout` 將各自做為輸入和輸出的預設值。" #: ../../library/json.rst:697 msgid "" "The output is now in the same order as the input. Use the :option:`--sort-" "keys` option to sort the output of dictionaries alphabetically by key." msgstr "" +"現在開始輸出和輸入的資料順序會是相同的。傳入 :option:`--sort-keys` 引數以按照" +"鍵值的字母順序對輸出進行排序。" #: ../../library/json.rst:704 msgid "Command line options" @@ -852,39 +973,41 @@ msgstr "命令列選項" #: ../../library/json.rst:708 msgid "The JSON file to be validated or pretty-printed:" -msgstr "" +msgstr "將被用於校驗或美化呈現的 JSON 文件:" #: ../../library/json.rst:724 msgid "If *infile* is not specified, read from :data:`sys.stdin`." -msgstr "" +msgstr "如果沒有指定 *infile* 則會從 :data:`sys.stdin` 讀取輸入。" #: ../../library/json.rst:728 msgid "" "Write the output of the *infile* to the given *outfile*. Otherwise, write it " "to :data:`sys.stdout`." msgstr "" +"將 *infile* 的結果寫入到給定的 *outfile*。若未提供則寫入到 :data:`sys." +"stdout`。" #: ../../library/json.rst:733 msgid "Sort the output of dictionaries alphabetically by key." -msgstr "" +msgstr "按照鍵值的字母順序對輸出字典進行排序。" #: ../../library/json.rst:739 msgid "" "Disable escaping of non-ascii characters, see :func:`json.dumps` for more " "information." -msgstr "" +msgstr "關閉非 ASCII 字元的自動轉義功能。詳情請參照 :func:`json.dumps`。" #: ../../library/json.rst:745 msgid "Parse every input line as separate JSON object." -msgstr "" +msgstr "將每一行輸入都單獨輸出為一個 JSON 物件。" #: ../../library/json.rst:751 msgid "Mutually exclusive options for whitespace control." -msgstr "" +msgstr "互斥的空白字元控制選項。" #: ../../library/json.rst:757 msgid "Show the help message." -msgstr "" +msgstr "顯示說明訊息。" #: ../../library/json.rst:761 msgid "Footnotes" @@ -897,3 +1020,6 @@ msgid "" "and U+2029 (PARAGRAPH SEPARATOR) characters in strings, whereas JavaScript " "(as of ECMAScript Edition 5.1) does not." msgstr "" +"如 `RFC 7159 更正 `_ " +"所述,JSON 允許字串中出現 U+2028(列分隔符)和 U+2029(段落分隔符)字元,而 " +"JavaScript(截至 ECMAScript 5.1 版)則不允許。" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy