@@ -150,7 +150,7 @@ msgid ""
150
150
"reference check for container types will be skipped and a circular reference "
151
151
"will result in a :exc:`RecursionError` (or worse)."
152
152
msgstr ""
153
- "如果 *chech_circular * 設為 false(預設是 ``True``),則針對不同容器型別的循環"
153
+ "如果 *check_circular * 設為 false(預設是 ``True``),則針對不同容器型別的循環"
154
154
"參照 (circular reference) 的檢查將會被跳過,若有循環參照則最後將引發 :exc:"
155
155
"`RecursionError` (或者更糟的錯誤)。"
156
156
@@ -162,6 +162,11 @@ msgid ""
162
162
"*allow_nan* is true, their JavaScript equivalents (``NaN``, ``Infinity``, ``-"
163
163
"Infinity``) will be used."
164
164
msgstr ""
165
+ "如果 *allow_nan* 設為 False(預設值為 ``True``),那麼序列化 (serialize):"
166
+ "class:`float` 的特殊值 (``nan``, ``inf``, ``-inf``) 會觸發 :exc:"
167
+ "`ValueError`,這麼設定是為了遵守較嚴格的 JSON 規範。如果設為 True,則序列化這"
168
+ "些極值不會出錯,而是會被自動代換成 JavaScript 上等價的值 (``NaN``, "
169
+ "``Infinity``, ``-Infinity``)"
165
170
166
171
#: ../../library/json.rst:168 ../../library/json.rst:452
167
172
msgid ""
@@ -172,10 +177,12 @@ msgid ""
172
177
"indent indents that many spaces per level. If *indent* is a string (such as "
173
178
"``\"\\ t\" ``), that string is used to indent each level."
174
179
msgstr ""
180
+ "如果 *indent* 是一個非負整數或字串,那麼 JSON 序列及其所含元素,會以pretty-"
181
+ "print 的方式顯示,並會有幾個。"
175
182
176
183
#: ../../library/json.rst:175 ../../library/json.rst:459
177
184
msgid "Allow strings for *indent* in addition to integers."
178
- msgstr ""
185
+ msgstr "允許字串作為 *indent* 的值,而不只是允許整數。 "
179
186
180
187
#: ../../library/json.rst:178 ../../library/json.rst:462
181
188
msgid ""
@@ -184,10 +191,14 @@ msgid ""
184
191
"': ')`` otherwise. To get the most compact JSON representation, you should "
185
192
"specify ``(',', ':')`` to eliminate whitespace."
186
193
msgstr ""
194
+ "*separator* 是分隔符號,``( 項跟項 (item) 之間的分隔符號, 鍵值 (key) 之間的分"
195
+ "隔符號)`` 的 tuple。 如果 *indent* 是 ``None``,則預設值為 ``(', ', ': ')``,"
196
+ "否則預設值為 ``(',', ': ')``。如果希望 JSON 更省空間,建議指定為 ``(',', "
197
+ "':')``,這樣可以消除空白。"
187
198
188
199
#: ../../library/json.rst:183 ../../library/json.rst:467
189
200
msgid "Use ``(',', ': ')`` as default if *indent* is not ``None``."
190
- msgstr ""
201
+ msgstr "如果 *indent* 不是 ``None``,則用 ``(',', ': ')`` 當預設值 "
191
202
192
203
#: ../../library/json.rst:186 ../../library/json.rst:470
193
204
msgid ""
@@ -196,38 +207,53 @@ msgid ""
196
207
"version of the object or raise a :exc:`TypeError`. If not specified, :exc:"
197
208
"`TypeError` is raised."
198
209
msgstr ""
210
+ "*default* 必須一個函式,如果你有設定它的話,遇到無法 JSON 序列化的物件時會呼"
211
+ "叫你 *default* 設定的函式。該函式只能有兩種狀況:要不就回傳一個可以被 JSON 序"
212
+ "列化的物件,要不就拋出 :exc:`TypeError`。如果 *default* 沒有指定值,則只要遇"
213
+ "到無法 JSON 序列化的物件就會丟出 :exc:`TypeError`。"
199
214
200
215
#: ../../library/json.rst:191
201
216
msgid ""
202
217
"If *sort_keys* is true (default: ``False``), then the output of dictionaries "
203
218
"will be sorted by key."
204
219
msgstr ""
220
+ "如果 *sort_keys* 設為 True(預設值為 False),那麼字典的輸出會按照 "
221
+ "*sort_keys* 排序。"
205
222
206
223
#: ../../library/json.rst:194
207
224
msgid ""
208
225
"To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the :"
209
226
"meth:`~JSONEncoder.default` method to serialize additional types), specify "
210
227
"it with the *cls* kwarg; otherwise :class:`JSONEncoder` is used."
211
228
msgstr ""
229
+ "如果要使用自訂的 :class:`JSONEncoder` 子類別去改寫 (overrides)原來預設的 "
230
+ "meth:`~JSONEncoder.default`,請標明 *cls* 以序列化更多不同的型別。如果沒有標"
231
+ "的話,就會使用 :class:`JSONEncoder` 來序列化。"
212
232
213
233
#: ../../library/json.rst:198 ../../library/json.rst:277
214
234
msgid ""
215
235
"All optional parameters are now :ref:`keyword-only <keyword-only_parameter>`."
216
236
msgstr ""
237
+ "所有非必要參數現在都是 :ref:`keyword-only <keyword-only_parameter>` 了。"
217
238
218
239
#: ../../library/json.rst:203
219
240
msgid ""
220
241
"Unlike :mod:`pickle` and :mod:`marshal`, JSON is not a framed protocol, so "
221
242
"trying to serialize multiple objects with repeated calls to :func:`dump` "
222
243
"using the same *fp* will result in an invalid JSON file."
223
244
msgstr ""
245
+ "JSON 和 :mod:`pickle` 跟 :mod:`marshal` 不同,JSON不是一個框架協定,所以如果"
246
+ "你試著用同一個 *fp* 來重複呼叫 :func:`dump` 來序列化多個物件,會導致無效的"
247
+ "JSON檔案。"
224
248
225
249
#: ../../library/json.rst:212
226
250
msgid ""
227
251
"Serialize *obj* to a JSON formatted :class:`str` using this :ref:`conversion "
228
252
"table <py-to-json-table>`. The arguments have the same meaning as in :func:"
229
253
"`dump`."
230
254
msgstr ""
255
+ "用這個 :ref:`conversion table <py-to-json-table>` 來把 *obj* 序列化成JSON 格"
256
+ "式的 :class:`str`。 裡面所有引數和 :func: `dump` 裡的意義相同。"
231
257
232
258
#: ../../library/json.rst:218
233
259
msgid ""
@@ -237,13 +263,20 @@ msgid ""
237
263
"JSON and then back into a dictionary, the dictionary may not equal the "
238
264
"original one. That is, ``loads(dumps(x)) != x`` if x has non-string keys."
239
265
msgstr ""
266
+ "在 JSON 的 鍵值/值對 (key/value pairs) 中,鍵值一定是 :class:`str`。當一個字"
267
+ "典物件 (dictionary) 被轉換成 JSON 時,字典的所有鍵都會被強制轉換成字串。因"
268
+ "此,如果一個字典被轉換成 JSON 然後再轉回字典,該字典可能不等於原來的字典。也"
269
+ "就是說,如果字典 x 有些鍵值不是字串,那麼 ``loads(dumps(x)) != x``。"
240
270
241
271
#: ../../library/json.rst:227
242
272
msgid ""
243
273
"Deserialize *fp* (a ``.read()``-supporting :term:`text file` or :term:"
244
274
"`binary file` containing a JSON document) to a Python object using this :ref:"
245
275
"`conversion table <json-to-py-table>`."
246
276
msgstr ""
277
+ "將 fp(一個支持.read() 的 :term:`text file` 或包含 JSON 的:term:`binary "
278
+ "file` 反序列化 (deserialize) 為 Python 物件,轉換規則使用`conversion table "
279
+ "<json-to-py-table>`。"
247
280
248
281
#: ../../library/json.rst:231
249
282
msgid ""
@@ -253,6 +286,10 @@ msgid ""
253
286
"be used to implement custom decoders (e.g. `JSON-RPC <https://www.jsonrpc."
254
287
"org>`_ class hinting)."
255
288
msgstr ""
289
+ "*object_hook* 是一個非必要性的函式,用來解碼物件 object_literal。如果沒有值"
290
+ "時,物件會被解碼成 :class:`dict`。如果有值,會 *object_hook* 的回傳值會被用來"
291
+ "取代原來的 :class:`dict`。因此,改寫 *object_hook* 就能自訂的解碼器(例如"
292
+ "`JSON-RPC <https://www.jsonrpc.org>`_ 類別提示)。"
256
293
257
294
#: ../../library/json.rst:237
258
295
msgid ""
@@ -262,6 +299,10 @@ msgid ""
262
299
"`dict`. This feature can be used to implement custom decoders. If "
263
300
"*object_hook* is also defined, the *object_pairs_hook* takes priority."
264
301
msgstr ""
302
+ "*object_pairs_hook* 是一個非必要函式,會在解碼物件成有序值對陣列(暫譯,"
303
+ "ordered list of pairs),如果有值,JSON 會使用 *object_pairs_hook* 的回傳值而"
304
+ "非原本的 :class:`dict`。此功能可以用來自訂解碼器。如果 *object_hook*也有值,"
305
+ "*object_pairs_hook* 的值會優先採用。"
265
306
266
307
#: ../../library/json.rst:243 ../../library/json.rst:348
267
308
msgid "Added support for *object_pairs_hook*."
@@ -274,6 +315,9 @@ msgid ""
274
315
"This can be used to use another datatype or parser for JSON floats (e.g. :"
275
316
"class:`decimal.Decimal`)."
276
317
msgstr ""
318
+ "如果 *parse_float* 有值,含浮點數的 JSON 文字會被解析。預設是"
319
+ "``float(num_str)``,但可以設成別的資料型別或 JSON 浮點數文字解析器,例如:"
320
+ "class:`decimal.Decimal`。"
277
321
278
322
#: ../../library/json.rst:251 ../../library/json.rst:356
279
323
msgid ""
@@ -282,24 +326,31 @@ msgid ""
282
326
"can be used to use another datatype or parser for JSON integers (e.g. :class:"
283
327
"`float`)."
284
328
msgstr ""
329
+ "如果 *parse_int* 有值,含整數的 JSON 文字會被解析。預設是``int(num_str)``,但"
330
+ "可以設成別的資料型別或 JSON 整數文字解析器,例如:class:`float`。"
285
331
286
332
#: ../../library/json.rst:256
287
333
msgid ""
288
334
"The default *parse_int* of :func:`int` now limits the maximum length of the "
289
335
"integer string via the interpreter's :ref:`integer string conversion length "
290
336
"limitation <int_max_str_digits>` to help avoid denial of service attacks."
291
337
msgstr ""
338
+ ":func:`int` 預設的 *parse_int* 現在有字數上限了,上限是直譯器的:ref:`integer "
339
+ "string conversion length limitation <int_max_str_digits>`"
292
340
293
341
#: ../../library/json.rst:262 ../../library/json.rst:361
294
342
msgid ""
295
343
"*parse_constant*, if specified, will be called with one of the following "
296
344
"strings: ``'-Infinity'``, ``'Infinity'``, ``'NaN'``. This can be used to "
297
345
"raise an exception if invalid JSON numbers are encountered."
298
346
msgstr ""
347
+ "如果 *parse_constant* 有值,那麼遇到 ``'-Infinity'``、``'Infinity'``或"
348
+ "``'NaN'``等字串時,會被呼叫用以解析它們。 *parse_constant* 也可是設定成在遇在"
349
+ "遇無效的 JSON 數字時出錯。"
299
350
300
351
#: ../../library/json.rst:267
301
352
msgid "*parse_constant* doesn't get called on 'null', 'true', 'false' anymore."
302
- msgstr ""
353
+ msgstr "*parse_constant* 不再在遇到 'null'、 'true'、 'false' 呼叫了。 "
303
354
304
355
#: ../../library/json.rst:270
305
356
msgid ""
0 commit comments