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
ea8b6ef1
Kaydet (Commit)
ea8b6ef1
authored
Nis 13, 2011
tarafından
R David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#10019: Fix regression relative to 2.6: add newlines if indent=0
Patch by Amaury Forgeot d'Arc, updated by Sando Tosi.
üst
49c44087
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
4 deletions
+23
-4
json.rst
Doc/library/json.rst
+3
-3
encoder.py
Lib/json/encoder.py
+1
-1
test_indent.py
Lib/json/tests/test_indent.py
+16
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/json.rst
Dosyayı görüntüle @
ea8b6ef1
...
...
@@ -139,9 +139,9 @@ Basic Usage
using the JavaScript equivalents (``NaN``, ``Infinity``, ``-Infinity``).
If *indent* is a non-negative integer, then JSON array elements and object
members will be pretty-printed with that indent level. An indent level of 0
will only insert newlines. ``None`` (the default) selects the most compact
representation.
members will be pretty-printed with that indent level. An indent level of 0
,
or negative, will only insert newlines. ``None`` (the default) selects the
most compact
representation.
If *separators* is an ``(item_separator, dict_separator)`` tuple, then it
will be used instead of the default ``(', ', ': ')`` separators. ``(',',
...
...
Lib/json/encoder.py
Dosyayı görüntüle @
ea8b6ef1
...
...
@@ -251,7 +251,7 @@ class JSONEncoder(object):
if
(
_one_shot
and
c_make_encoder
is
not
None
and
not
self
.
indent
and
not
self
.
sort_keys
):
and
self
.
indent
is
None
and
not
self
.
sort_keys
):
_iterencode
=
c_make_encoder
(
markers
,
self
.
default
,
_encoder
,
self
.
indent
,
self
.
key_separator
,
self
.
item_separator
,
self
.
sort_keys
,
...
...
Lib/json/tests/test_indent.py
Dosyayı görüntüle @
ea8b6ef1
...
...
@@ -2,6 +2,7 @@ from unittest import TestCase
import
json
import
textwrap
from
StringIO
import
StringIO
class
TestIndent
(
TestCase
):
def
test_indent
(
self
):
...
...
@@ -39,3 +40,18 @@ class TestIndent(TestCase):
self
.
assertEqual
(
h1
,
h
)
self
.
assertEqual
(
h2
,
h
)
self
.
assertEqual
(
d2
,
expect
)
def
test_indent0
(
self
):
h
=
{
3
:
1
}
def
check
(
indent
,
expected
):
d1
=
json
.
dumps
(
h
,
indent
=
indent
)
self
.
assertEqual
(
d1
,
expected
)
sio
=
StringIO
()
json
.
dump
(
h
,
sio
,
indent
=
indent
)
self
.
assertEqual
(
sio
.
getvalue
(),
expected
)
# indent=0 should emit newlines
check
(
0
,
'{
\n
"3": 1
\n
}'
)
# indent=None is more compact
check
(
None
,
'{"3": 1}'
)
Misc/NEWS
Dosyayı görüntüle @
ea8b6ef1
...
...
@@ -51,6 +51,9 @@ Core and Builtins
Library
-------
- Issue #10019: Fixed regression in json module where an indent of 0 stopped
adding newlines and acted instead like '
None
'.
- Issue #5162: Treat services like frozen executables to allow child spawning
from multiprocessing.forking on Windows.
...
...
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