Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ee047e58
Kaydet (Commit)
ee047e58
authored
Haz 30, 2016
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #4945: Improved the documenting of boolean arguments in the json module.
Based on patch by Gabriel Genellina.
üst
60a7ec3b
15287f8b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
24 deletions
+28
-24
json.rst
Doc/library/json.rst
+26
-22
__init__.py
Lib/json/__init__.py
+2
-2
No files found.
Doc/library/json.rst
Dosyayı görüntüle @
ee047e58
...
...
@@ -102,7 +102,7 @@ Extending :class:`JSONEncoder`::
.. highlight:: bash
Using
json.tool
from the shell to validate and pretty-print::
Using
:mod:`json.tool`
from the shell to validate and pretty-print::
$ echo '{"json":"obj"}' | python -m json.tool
{
...
...
@@ -135,7 +135,7 @@ Basic Usage
:term:`file-like object`) using this :ref:`conversion table
<py-to-json-table>`.
If *skipkeys* is
``True``
(default: ``False``), then dict keys that are not
If *skipkeys* is
true
(default: ``False``), then dict 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`.
...
...
@@ -143,18 +143,19 @@ Basic Usage
:class:`bytes` objects. Therefore, ``fp.write()`` must support :class:`str`
input.
If *ensure_ascii* is
``True``
(the default), the output is guaranteed to
If *ensure_ascii* is
true
(the default), the output is guaranteed to
have all incoming non-ASCII characters escaped. If *ensure_ascii* is
``False``
, these characters will be output as-is.
false
, these characters will be output as-is.
If *check_circular* is
``False``
(default: ``True``), then the circular
If *check_circular* is
false
(default: ``True``), then the circular
reference check for container types will be skipped and a circular reference
will result in an :exc:`OverflowError` (or worse).
If *allow_nan* is
``False``
(default: ``True``), then it will be a
If *allow_nan* is
false
(default: ``True``), then it will be a
:exc:`ValueError` to serialize out of range :class:`float` values (``nan``,
``inf``, ``-inf``) in strict compliance of the JSON specification, instead of
using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
``inf``, ``-inf``) in strict compliance of the JSON specification.
If *allow_nan* is true, their JavaScript equivalents (``NaN``,
``Infinity``, ``-Infinity``) will be used.
If *indent* is a non-negative integer or string, then JSON array elements and
object members will be pretty-printed with that indent level. An indent level
...
...
@@ -174,10 +175,12 @@ Basic Usage
.. versionchanged:: 3.4
Use ``(',', ': ')`` as default if *indent* is not ``None``.
*default(obj)* is a function that should return a serializable version of
*obj* or raise :exc:`TypeError`. The default simply raises :exc:`TypeError`.
If specified, *default* should be a function that gets 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 not specified, :exc:`TypeError`
is raised.
If *sort_keys* is
``True``
(default: ``False``), then the output of
If *sort_keys* is
true
(default: ``False``), then the output of
dictionaries will be sorted by key.
To use a custom :class:`JSONEncoder` subclass (e.g. one that overrides the
...
...
@@ -339,7 +342,7 @@ Encoders and Decoders
``'false'``. This can be used to raise an exception if invalid JSON numbers
are encountered.
If *strict* is
``False``
(``True`` is the default), then control characters
If *strict* is
false
(``True`` is the default), then control characters
will be allowed inside strings. Control characters in this context are
those with character codes in the 0-31 range, including ``'\t'`` (tab),
``'\n'``, ``'\r'`` and ``'\0'``.
...
...
@@ -402,26 +405,26 @@ Encoders and Decoders
for ``o`` if possible, otherwise it should call the superclass implementation
(to raise :exc:`TypeError`).
If *skipkeys* is
``False``
(the default), then it is a :exc:`TypeError` to
If *skipkeys* is
false
(the default), then it is a :exc:`TypeError` to
attempt encoding of keys that are not str, int, float or None. If
*skipkeys* is
``True``
, such items are simply skipped.
*skipkeys* is
true
, such items are simply skipped.
If *ensure_ascii* is
``True``
(the default), the output is guaranteed to
If *ensure_ascii* is
true
(the default), the output is guaranteed to
have all incoming non-ASCII characters escaped. If *ensure_ascii* is
``False``
, these characters will be output as-is.
false
, these characters will be output as-is.
If *check_circular* is
``True``
(the default), then lists, dicts, and custom
If *check_circular* is
true
(the default), then lists, dicts, and custom
encoded objects will be checked for circular references during encoding to
prevent an infinite recursion (which would cause an :exc:`OverflowError`).
Otherwise, no such check takes place.
If *allow_nan* is
``True``
(the default), then ``NaN``, ``Infinity``, and
If *allow_nan* is
true
(the default), then ``NaN``, ``Infinity``, and
``-Infinity`` will be encoded as such. This behavior is not JSON
specification compliant, but is consistent with most JavaScript based
encoders and decoders. Otherwise, it will be a :exc:`ValueError` to encode
such floats.
If *sort_keys* is
``True`` (default
``False``), then the output of dictionaries
If *sort_keys* is
true (default:
``False``), then the output of dictionaries
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.
...
...
@@ -443,9 +446,10 @@ Encoders and Decoders
.. versionchanged:: 3.4
Use ``(',', ': ')`` as default if *indent* is not ``None``.
If specified, *default* is a function that gets 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 specified, *default* should be a function that gets 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 not specified, :exc:`TypeError`
is raised.
.. versionchanged:: 3.6
All parameters are now :ref:`keyword-only <keyword-only_parameter>`.
...
...
Lib/json/__init__.py
Dosyayı görüntüle @
ee047e58
...
...
@@ -152,7 +152,7 @@ def dump(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True,
``default(obj)`` is a function that should return a serializable version
of obj or raise TypeError. The default simply raises TypeError.
If *sort_keys* is
``True``
(default: ``False``), then the output of
If *sort_keys* is
true
(default: ``False``), then the output of
dictionaries will be sorted by key.
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
...
...
@@ -214,7 +214,7 @@ def dumps(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True,
``default(obj)`` is a function that should return a serializable version
of obj or raise TypeError. The default simply raises TypeError.
If *sort_keys* is
``True``
(default: ``False``), then the output of
If *sort_keys* is
true
(default: ``False``), then the output of
dictionaries will be sorted by key.
To use a custom ``JSONEncoder`` subclass (e.g. one that overrides the
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment