diff -r a2bf6d1e018e Doc/library/json.rst --- a/Doc/library/json.rst Fri Mar 18 13:24:15 2016 -0700 +++ b/Doc/library/json.rst Fri Mar 18 14:18:59 2016 -0700 @@ -121,6 +121,13 @@ Basic Usage ----------- +.. attribute:: JSONType + + A type representing JSON data. Due to the lack of support for recursive types + in the :mod:`typing` module, the type for what dictionaries and lists can + hold is specified as :class:`typing.Any`. + + .. function:: dump(obj, fp, skipkeys=False, ensure_ascii=True, \ check_circular=True, allow_nan=True, cls=None, \ indent=None, separators=None, default=None, \ diff -r a2bf6d1e018e Lib/json/__init__.py --- a/Lib/json/__init__.py Fri Mar 18 13:24:15 2016 -0700 +++ b/Lib/json/__init__.py Fri Mar 18 14:18:59 2016 -0700 @@ -98,11 +98,13 @@ __version__ = '2.0.9' __all__ = [ 'dump', 'dumps', 'load', 'loads', - 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', + 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder', 'JSONType' ] __author__ = 'Bob Ippolito ' +import typing as t + from .decoder import JSONDecoder, JSONDecodeError from .encoder import JSONEncoder @@ -116,6 +118,9 @@ default=None, ) +JSONType = t.Union[str, int, float, bool, None, t.Dict[str, t.Any], + t.List[t.Any]] + def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw):