From 732fa756a402340224c862bddbf905d41e6491ee Mon Sep 17 00:00:00 2001 From: Florent Xicluna Date: Wed, 28 Jul 2010 16:39:41 +0000 Subject: Syntax cleanup. --- Lib/json/encoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/json/encoder.py') diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index 2beb10e358..d068e72216 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -397,7 +397,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, yield 'true' elif o is False: yield 'false' - elif isinstance(o, (int, int)): + elif isinstance(o, int): yield str(o) elif isinstance(o, float): yield _floatstr(o) -- cgit v1.2.1 From cc0118baa35ec04b27adee09b93a6d71fbf92946 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 2 Aug 2010 20:16:18 +0000 Subject: #9087: update json docstrings -- unicode and long do not exist anymore. --- Lib/json/encoder.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Lib/json/encoder.py') diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index d068e72216..13359856d2 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -77,9 +77,9 @@ class JSONEncoder(object): +-------------------+---------------+ | list, tuple | array | +-------------------+---------------+ - | str, unicode | string | + | str | string | +-------------------+---------------+ - | int, long, float | number | + | int, float | number | +-------------------+---------------+ | True | true | +-------------------+---------------+ @@ -102,12 +102,12 @@ class JSONEncoder(object): """Constructor for JSONEncoder, with sensible defaults. If skipkeys is false, then it is a TypeError to attempt - encoding of keys that are not str, int, long, float or None. If + encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped. If ensure_ascii is true, the output is guaranteed to be str - objects with all incoming unicode characters escaped. If - ensure_ascii is false, the output will be unicode object. + objects with all incoming non-ASCII characters escaped. If + ensure_ascii is false, the output can contain non-ASCII characters. If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to -- cgit v1.2.1 From db857f8e443f541bc476ad31d43b27f2a8875ae4 Mon Sep 17 00:00:00 2001 From: Raymond Hettinger Date: Sun, 31 Oct 2010 08:00:16 +0000 Subject: Issue #5729: json.dumps to support using '\t' as an indent string --- Lib/json/encoder.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'Lib/json/encoder.py') diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py index 13359856d2..7475f5a544 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -259,6 +259,9 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, tuple=tuple, ): + if _indent is not None and not isinstance(_indent, str): + _indent = ' ' * _indent + def _iterencode_list(lst, _current_indent_level): if not lst: yield '[]' @@ -271,7 +274,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, buf = '[' if _indent is not None: _current_indent_level += 1 - newline_indent = '\n' + (' ' * (_indent * _current_indent_level)) + newline_indent = '\n' + _indent * _current_indent_level separator = _item_separator + newline_indent buf += newline_indent else: @@ -307,7 +310,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, yield chunk if newline_indent is not None: _current_indent_level -= 1 - yield '\n' + (' ' * (_indent * _current_indent_level)) + yield '\n' + _indent * _current_indent_level yield ']' if markers is not None: del markers[markerid] @@ -324,7 +327,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, yield '{' if _indent is not None: _current_indent_level += 1 - newline_indent = '\n' + (' ' * (_indent * _current_indent_level)) + newline_indent = '\n' + _indent * _current_indent_level item_separator = _item_separator + newline_indent yield newline_indent else: @@ -383,7 +386,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr, yield chunk if newline_indent is not None: _current_indent_level -= 1 - yield '\n' + (' ' * (_indent * _current_indent_level)) + yield '\n' + _indent * _current_indent_level yield '}' if markers is not None: del markers[markerid] -- cgit v1.2.1