Aestate
Public Member Functions | Public Attributes | List of all members
aestate.ajson.sim.decoder.JSONDecoder Class Reference
Inheritance diagram for aestate.ajson.sim.decoder.JSONDecoder:
Inheritance graph
Collaboration diagram for aestate.ajson.sim.decoder.JSONDecoder:
Collaboration graph

Public Member Functions

def __init__ (self, encoding=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)
 
def decode (self, s, _w=WHITESPACE.match, _PY3=PY3)
 
def raw_decode (self, s, idx=0, _w=WHITESPACE.match, _PY3=PY3)
 

Public Attributes

 encoding
 
 object_hook
 
 object_pairs_hook
 
 parse_float
 
 parse_int
 
 parse_constant
 
 strict
 
 parse_object
 
 parse_array
 
 parse_string
 
 memo
 
 scan_once
 

Detailed Description

Simple JSON <http://json.org> decoder

Performs the following translations in decoding by default:

+---------------+-------------------+
| JSON          | Python            |
+===============+===================+
| object        | dict              |
+---------------+-------------------+
| array         | list              |
+---------------+-------------------+
| string        | str, unicode      |
+---------------+-------------------+
| number (int)  | int, long         |
+---------------+-------------------+
| number (real) | float             |
+---------------+-------------------+
| true          | True              |
+---------------+-------------------+
| false         | False             |
+---------------+-------------------+
| null          | None              |
+---------------+-------------------+

It also understands ``NaN``, ``Infinity``, and ``-Infinity`` as
their corresponding ``float`` values, which is outside the JSON spec.

Definition at line 281 of file decoder.py.

Constructor & Destructor Documentation

◆ __init__()

def aestate.ajson.sim.decoder.JSONDecoder.__init__ (   self,
  encoding = None,
  object_hook = None,
  parse_float = None,
  parse_int = None,
  parse_constant = None,
  strict = True,
  object_pairs_hook = None 
)
*encoding* 确定用于解释任何
:class:`str` 对象由此实例解码 (``'utf-8'`` by
默认)。它在解码 unicode 对象时不起作用。

请注意,目前只有作为 ASCII 超集的编码才有效,
其他编码的字符串应该作为 unicode 传入。

*object_hook*,如果指定,将使用每个的结果调用
解码后的 JSON 对象及其返回值将用于代替
给定:class:`dict`。这可用于提供自定义
反序列化(例如支持 JSON-RPC 类提示)。

*object_pairs_hook* 是一个可选函数,将被调用
使用有序的对列表解码任何对象文字的结果。
将使用 *object_pairs_hook* 的返回值代替
:class:`字典`。此功能可用于实现自定义解码器
依赖于键和值对解码的顺序(对于
例如,:func:`collections.OrderedDict` 会记住
插入)。如果还定义了 *object_hook*,则 *object_pairs_hook*
优先。

*parse_float*,如果指定,将使用每个的字符串调用
要解码的 JSON 浮点数。默认情况下,这相当于
``浮动(num_str)``。这可用于使用其他数据类型或解析器
对于 JSON 浮点数(例如 :class:`decimal.Decimal`)。

* parse_int *(如果指定)将使用每个字符串
要解码的 JSON int。默认情况下,这相当于
``int(num_str)``。这可用于使用其他数据类型或解析器
对于 JSON 整数(例如 :class:`float`)。

*parse_constant*,如果指定,将使用以下之一调用
以下字符串:“-Infinity”、“Infinity”、“NaN”。这
如果无效的JSON数字为,则可用于引发异常
遭遇。

*strict* 控制解析器在遇到
字符串中的无效控制字符。默认设置为
``True`` 表示未转义的控制字符是解析错误,如果
``False`` 那么字符串中将允许使用控制字符

Definition at line 311 of file decoder.py.

Member Function Documentation

◆ decode()

def aestate.ajson.sim.decoder.JSONDecoder.decode (   self,
  s,
  _w = WHITESPACE.match,
  _PY3 = PY3 
)
返回 ``s`` 的 Python 表示(一个 ``str`` 或 ``unicode``

包含 JSON 文档的实例)

Definition at line 372 of file decoder.py.

Here is the call graph for this function:

◆ raw_decode()

def aestate.ajson.sim.decoder.JSONDecoder.raw_decode (   self,
  s,
  idx = 0,
  _w = WHITESPACE.match,
  _PY3 = PY3 
)
 从一个str或unicode解码一个 JSON 文档

 以 JSON 文档开头)并返回 Python 的 2 元组

 表示和 s 中文档结束的索引。

 可选地,``idx`` 可用于指定 ``s`` 中的偏移量

 这可用于从字符串解码 JSON 文档,该字符串可能
 最后有多余的数据。

Definition at line 386 of file decoder.py.

Here is the caller graph for this function:

Member Data Documentation

◆ encoding

aestate.ajson.sim.decoder.JSONDecoder.encoding

Definition at line 357 of file decoder.py.

◆ memo

aestate.ajson.sim.decoder.JSONDecoder.memo

Definition at line 367 of file decoder.py.

◆ object_hook

aestate.ajson.sim.decoder.JSONDecoder.object_hook

Definition at line 358 of file decoder.py.

◆ object_pairs_hook

aestate.ajson.sim.decoder.JSONDecoder.object_pairs_hook

Definition at line 359 of file decoder.py.

◆ parse_array

aestate.ajson.sim.decoder.JSONDecoder.parse_array

Definition at line 365 of file decoder.py.

◆ parse_constant

aestate.ajson.sim.decoder.JSONDecoder.parse_constant

Definition at line 362 of file decoder.py.

◆ parse_float

aestate.ajson.sim.decoder.JSONDecoder.parse_float

Definition at line 360 of file decoder.py.

◆ parse_int

aestate.ajson.sim.decoder.JSONDecoder.parse_int

Definition at line 361 of file decoder.py.

◆ parse_object

aestate.ajson.sim.decoder.JSONDecoder.parse_object

Definition at line 364 of file decoder.py.

◆ parse_string

aestate.ajson.sim.decoder.JSONDecoder.parse_string

Definition at line 366 of file decoder.py.

◆ scan_once

aestate.ajson.sim.decoder.JSONDecoder.scan_once

Definition at line 368 of file decoder.py.

◆ strict

aestate.ajson.sim.decoder.JSONDecoder.strict

Definition at line 363 of file decoder.py.


The documentation for this class was generated from the following file: