Help on module demjson: NAME demjson - A JSON data encoder and decoder. FILE demjson.py DESCRIPTION This Python module implements the JSON (http://json.org/) data encoding format; a subset of ECMAScript (aka JavaScript) for encoding primitive data types (numbers, strings, booleans, lists, and associative arrays) in a language-neutral simple text-based syntax. It can encode or decode between JSON formatted strings and native Python data types. Normally you would use the encode() and decode() functions defined by this module, but if you want more control over the processing you can use the JSON class. This implementation tries to be as completely cormforming to all intricacies of the standards as possible. It can operate in strict mode (which only allows JSON-compliant syntax) or a non-strict mode (which allows much more of the whole ECMAScript permitted syntax). This includes complete support for Unicode strings (including surrogate-pairs for non-BMP characters), and all number formats including negative zero and IEEE 754 non-numbers such a NaN or Infinity. The JSON/ECMAScript to Python type mappings are: ---JSON--- ---Python--- null None undefined undefined (note 1) Boolean (true,false) bool (True or False) Integer int or long (note 2) Float float String str or unicode ( "..." or u"..." ) Array [a, ...] list ( [...] ) Object {a:b, ...} dict ( {...} ) -- Note 1. an 'undefined' object is declared in this module which represents the native Python value for this type when in non-strict mode. -- Note 2. some ECMAScript integers may be up-converted to Python floats, such as 1e+40. Also integer -0 is converted to float -0, so as to preserve the sign (which ECMAScript requires). -- Note 3. numbers requiring more significant digits than can be represented by the Python float type will be converted into a Python Decimal type, from the standard 'decimal' module. In addition, when operating in non-strict mode, several IEEE 754 non-numbers are also handled, and are mapped to specific Python objects declared in this module: NaN (not a number) nan (float('nan')) Infinity, +Infinity inf (float('inf')) -Infinity neginf (float('-inf')) When encoding Python objects into JSON, you may use types other than native lists or dictionaries, as long as they support the minimal interfaces required of all sequences or mappings. This means you can use generators and iterators, tuples, UserDict subclasses, etc. To make it easier to produce JSON encoded representations of user defined classes, if the object has a method named json_equivalent(), then it will call that method and attempt to encode the object returned from it instead. It will do this recursively as needed and before any attempt to encode the object using it's default strategies. Note that any json_equivalent() method should return "equivalent" Python objects to be encoded, not an already-encoded JSON-formatted string. There is no such aid provided to decode JSON back into user-defined classes as that would dramatically complicate the interface. When decoding strings with this module it may operate in either strict or non-strict mode. The strict mode only allows syntax which is conforming to RFC 7159 (JSON), while the non-strict allows much more of the permissible ECMAScript syntax. The following are permitted when processing in NON-STRICT mode: * Unicode format control characters are allowed anywhere in the input. * All Unicode line terminator characters are recognized. * All Unicode white space characters are recognized. * The 'undefined' keyword is recognized. * Hexadecimal number literals are recognized (e.g., 0xA6, 0177). * String literals may use either single or double quote marks. * Strings may contain \x (hexadecimal) escape sequences, as well as the \v and \0 escape sequences. * Lists may have omitted (elided) elements, e.g., [,,,,,], with missing elements interpreted as 'undefined' values. * Object properties (dictionary keys) can be of any of the types: string literals, numbers, or identifiers (the later of which are treated as if they are string literals)---as permitted by ECMAScript. JSON only permits strings literals as keys. Concerning non-strict and non-ECMAScript allowances: * Octal numbers: If you allow the 'octal_numbers' behavior (which is never enabled by default), then you can use octal integers and octal character escape sequences (per the ECMAScript standard Annex B.1.2). This behavior is allowed, if enabled, because it was valid JavaScript at one time. * Multi-line string literals: Strings which are more than one line long (contain embedded raw newline characters) are never permitted. This is neither valid JSON nor ECMAScript. Some other JSON implementations may allow this, but this module considers that behavior to be a mistake. References: * JSON (JavaScript Object Notation) * RFC 7159. The application/json Media Type for JavaScript Object Notation (JSON) * ECMA-262 3rd edition (1999) * IEEE 754-1985: Standard for Binary Floating-Point Arithmetic. CLASSES __builtin__.long(__builtin__.object) json_int __builtin__.object JSON buffered_stream decode_state decode_statistics encode_state helpers json_options jsonlint position_marker codecs.CodecInfo(__builtin__.tuple) utf32 exceptions.Exception(exceptions.BaseException) JSONException JSONAbort JSONError JSONDecodeError JSONDecodeHookError JSONEncodeError JSONEncodeHookError JSONSkipHook JSONStopProcessing class JSON(__builtin__.object) | An encoder/decoder for JSON data streams. | | Usually you will call the encode() or decode() methods. The other | methods are for lower-level processing. | | Whether the JSON parser runs in strict mode (which enforces exact | compliance with the JSON spec) or the more forgiving non-string mode | can be affected by setting the 'strict' argument in the object's | initialization; or by assigning True or False to the 'strict' | property of the object. | | You can also adjust a finer-grained control over strictness by | allowing or forbidding specific behaviors. You can get a list of | all the available behaviors by accessing the 'behaviors' property. | Likewise the 'allowed_behaviors' and 'forbidden_behaviors' list which | behaviors will be allowed and which will not. Call the allow() | or forbid() methods to adjust these. | | Methods defined here: | | __init__(self, **kwargs) | Creates a JSON encoder/decoder object. | | You may pass encoding and decoding options either by passing | an argument named 'json_options' with an instance of a | json_options class; or with individual keyword/values that will | be used to initialize a new json_options object. | | You can also set hooks by using keyword arguments using the | hook name; e.g., encode_dict=my_hook_func. | | call_hook(self, hook_name, input_object, position=None, *args, **kwargs) | Wrapper function to invoke a user-supplied hook function. | | This will capture any exceptions raised by the hook and do something | appropriate with it. | | clear_all_hooks(self) | Unsets all hook callbacks, as previously set with set_hook(). | | clear_hook(self, hookname) | Unsets a hook callback, as previously set with set_hook(). | | decode(self, txt, encoding=None, return_errors=False, return_stats=False) | Decodes a JSON-encoded string into a Python object. | | The 'return_errors' parameter controls what happens if the | input JSON has errors in it. | | * False: the first error will be raised as a Python | exception. If there are no errors then the corresponding | Python object will be returned. | | * True: the return value is always a 2-tuple: (object, error_list) | | decode_boolean(self, state) | Intermediate-level decode for JSON boolean literals. | | Takes a string and a starting index, and returns a Python bool | (True or False) and the index of the next unparsed character. | | decode_composite(self, state) | Intermediate-level JSON decoder for composite literal types (array and object). | | decode_identifier(self, state, identifier_as_string=False) | Decodes an identifier/keyword. | | decode_javascript_identifier(self, name) | Convert a JavaScript identifier into a Python string object. | | This method can be overriden by a subclass to redefine how JavaScript | identifiers are turned into Python objects. By default this just | converts them into strings. | | decode_null(self, state) | Intermediate-level decoder for ECMAScript 'null' keyword. | | Takes a string and a starting index, and returns a Python | None object and the index of the next unparsed character. | | decode_number(self, state) | Intermediate-level decoder for JSON numeric literals. | | Takes a string and a starting index, and returns a Python | suitable numeric type and the index of the next unparsed character. | | The returned numeric type can be either of a Python int, | long, or float. In addition some special non-numbers may | also be returned such as nan, inf, and neginf (technically | which are Python floats, but have no numeric value.) | | Ref. ECMAScript section 8.5. | | decode_string(self, state) | Intermediate-level decoder for JSON string literals. | | Takes a string and a starting index, and returns a Python | string (or unicode string) and the index of the next unparsed | character. | | decodeobj(self, state, identifier_as_string=False, at_document_start=False) | Intermediate-level JSON decoder. | | Takes a string and a starting index, and returns a two-tuple consting | of a Python object and the index of the next unparsed character. | | If there is no value at all (empty string, etc), then None is | returned instead of a tuple. | | encode(self, obj, encoding=None) | Encodes the Python object into a JSON string representation. | | This method will first attempt to encode an object by seeing | if it has a json_equivalent() method. If so than it will | call that method and then recursively attempt to encode | the object resulting from that call. | | Next it will attempt to determine if the object is a native | type or acts like a squence or dictionary. If so it will | encode that object directly. | | Finally, if no other strategy for encoding the object of that | type exists, it will call the encode_default() method. That | method currently raises an error, but it could be overridden | by subclasses to provide a hook for extending the types which | can be encoded. | | encode_boolean(self, bval, state) | Encodes the Python boolean into a JSON Boolean literal. | | encode_composite(self, obj, state, obj_classification=None) | Encodes just composite objects: dictionaries, lists, or sequences. | | Basically handles any python type for which iter() can create | an iterator object. | | This method is not intended to be called directly. Use the | encode() method instead. | | encode_date(self, dt, state) | | encode_datetime(self, dt, state) | | encode_enum(self, val, state) | Encode a Python Enum value into JSON. | | encode_equivalent(self, obj, state) | This method is used to encode user-defined class objects. | | The object being encoded should have a json_equivalent() | method defined which returns another equivalent object which | is easily JSON-encoded. If the object in question has no | json_equivalent() method available then None is returned | instead of a string so that the encoding will attempt the next | strategy. | | If a caller wishes to disable the calling of json_equivalent() | methods, then subclass this class and override this method | to just return None. | | encode_null(self, state) | Produces the JSON 'null' keyword. | | encode_number(self, n, state) | Encodes a Python numeric type into a JSON numeric literal. | | The special non-numeric values of float('nan'), float('inf') | and float('-inf') are translated into appropriate JSON | literals. | | Note that Python complex types are not handled, as there is no | ECMAScript equivalent type. | | encode_string(self, s, state) | Encodes a Python string into a JSON string literal. | | encode_time(self, t, state) | | encode_timedelta(self, td, state) | | encode_undefined(self, state) | Produces the ECMAScript 'undefined' keyword. | | has_hook(self, hook_name) | | islineterm(self, c) | Determines if the given character is considered a line terminator. | | Ref. ECMAScript section 7.3 | | isws(self, c) | Determines if the given character is considered as white space. | | Note that Javscript is much more permissive on what it considers | to be whitespace than does JSON. | | Ref. ECMAScript section 7.2 | | recover_parser(self, state) | Try to recover after a syntax error by locating the next "known" position. | | set_hook(self, hookname, function) | Sets a user-defined callback function used during encoding or decoding. | | The 'hookname' argument must be a string containing the name of | one of the available hooks, listed below. | | The 'function' argument must either be None, which disables the hook, | or a callable function. Hooks do not stack, if you set a hook it will | undo any previously set hook. | | Netsted values. When decoding JSON that has nested objects or | arrays, the decoding hooks will be called once for every | corresponding value, even if nested. Generally the decoding | hooks will be called from the inner-most value outward, and | then left to right. | | Skipping. Any hook function may raise a JSONSkipHook exception | if it does not wish to handle the particular invocation. This | will have the effect of skipping the hook for that particular | value, as if the hook was net set. | | AVAILABLE HOOKS: | | * decode_string | Called for every JSON string literal with the | Python-equivalent string value as an argument. Expects to | get a Python object in return. | | * decode_float: | Called for every JSON number that looks like a float (has | a "."). The string representation of the number is passed | as an argument. Expects to get a Python object in return. | | * decode_number: | Called for every JSON number. The string representation of | the number is passed as an argument. Expects to get a | Python object in return. NOTE: If the number looks like a | float and the 'decode_float' hook is set, then this hook | will not be called. | | * decode_array: | Called for every JSON array. A Python list is passed as | the argument, and expects to get a Python object back. | NOTE: this hook will get called for every array, even | for nested arrays. | | * decode_object: | Called for every JSON object. A Python dictionary is passed | as the argument, and expects to get a Python object back. | NOTE: this hook will get called for every object, even | for nested objects. | | * encode_value: | Called for every Python object which is to be encoded into JSON. | | * encode_dict: | Called for every Python dictionary or anything that looks | like a dictionary. | | * encode_dict_key: | Called for every dictionary key. | | * encode_sequence: | Called for every Python sequence-like object that is not a | dictionary or string. This includes lists and tuples. | | * encode_bytes: | Called for every Python bytes or bytearray type; or for | any memoryview with a byte ('B') item type. (Python 3 only) | | * encode_default: | Called for any Python type which can not otherwise be converted | into JSON, even after applying any other encoding hooks. | | skip_comment(self, state) | Skips an ECMAScript comment, either // or /* style. | | The contents of the comment are returned as a string, as well | as the index of the character immediately after the comment. | | skipws(self, state) | Skips all whitespace, including comments and unicode whitespace | | Takes a string and a starting index, and returns the index of the | next non-whitespace character. | | If the 'skip_comments' behavior is True and not running in | strict JSON mode, then comments will be skipped over just like | whitespace. | | skipws_nocomments(self, state) | Skips whitespace (will not allow comments). | | try_encode_default(self, obj, state) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | options | The optional behaviors used, e.g., the JSON conformance | strictness. Returns an instance of json_options. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | all_hook_names = ('decode_number', 'decode_float', 'decode_object', 'd... | | json_syntax_characters = u'{}[]"\\,:0123456789.-+abcdefghijklmnopqrstu... class JSONAbort(JSONException) | Method resolution order: | JSONAbort | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from exceptions.Exception: | | __init__(...) | x.__init__(...) initializes x; see help(type(x)) for signature | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __repr__(...) | x.__repr__() <==> repr(x) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONDecodeError(JSONError) | An exception class raised when a JSON decoding error (syntax error) occurs. | | Method resolution order: | JSONDecodeError | JSONError | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods inherited from JSONError: | | __init__(self, message, *args, **kwargs) | | __repr__(self) | | pretty_description(self, show_positions=True, filename=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONError: | | position | | ---------------------------------------------------------------------- | Data and other attributes inherited from JSONError: | | severities = frozenset(['error', 'fatal', 'info', 'warning']) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONDecodeHookError(JSONDecodeError) | An exception that occured within a decoder hook. | | The original exception is available in the 'hook_exception' attribute. | | Method resolution order: | JSONDecodeHookError | JSONDecodeError | JSONError | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods defined here: | | __init__(self, hook_name, exc_info, encoded_obj, *args, **kwargs) | | ---------------------------------------------------------------------- | Methods inherited from JSONError: | | __repr__(self) | | pretty_description(self, show_positions=True, filename=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONError: | | position | | ---------------------------------------------------------------------- | Data and other attributes inherited from JSONError: | | severities = frozenset(['error', 'fatal', 'info', 'warning']) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONEncodeError(JSONError) | An exception class raised when a python object can not be encoded as a JSON string. | | Method resolution order: | JSONEncodeError | JSONError | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods inherited from JSONError: | | __init__(self, message, *args, **kwargs) | | __repr__(self) | | pretty_description(self, show_positions=True, filename=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONError: | | position | | ---------------------------------------------------------------------- | Data and other attributes inherited from JSONError: | | severities = frozenset(['error', 'fatal', 'info', 'warning']) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONEncodeHookError(JSONEncodeError) | An exception that occured within an encoder hook. | | The original exception is available in the 'hook_exception' attribute. | | Method resolution order: | JSONEncodeHookError | JSONEncodeError | JSONError | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods defined here: | | __init__(self, hook_name, exc_info, encoded_obj, *args, **kwargs) | | ---------------------------------------------------------------------- | Methods inherited from JSONError: | | __repr__(self) | | pretty_description(self, show_positions=True, filename=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONError: | | position | | ---------------------------------------------------------------------- | Data and other attributes inherited from JSONError: | | severities = frozenset(['error', 'fatal', 'info', 'warning']) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONError(JSONException) | Base class for all JSON-related errors. | | In addition to standard Python exceptions, these exceptions may | also have additional properties: | | * severity - One of: 'fatal', 'error', 'warning', 'info' | * position - An indication of the position in the input where the error occured. | * outer_position - A secondary position (optional) that gives | the location of the outer data item in which the error | occured, such as the beginning of a string or an array. | * context_description - A string that identifies the context | in which the error occured. Default is "Context". | | Method resolution order: | JSONError | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Methods defined here: | | __init__(self, message, *args, **kwargs) | | __repr__(self) | | pretty_description(self, show_positions=True, filename=None) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | position | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | severities = frozenset(['error', 'fatal', 'info', 'warning']) | | ---------------------------------------------------------------------- | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONException(exceptions.Exception) | Base class for all JSON-related exceptions. | | Method resolution order: | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from exceptions.Exception: | | __init__(...) | x.__init__(...) initializes x; see help(type(x)) for signature | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __repr__(...) | x.__repr__() <==> repr(x) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONSkipHook(JSONException) | An exception to be raised by user-defined code within hook | callbacks to indicate the callback does not want to handle the | situation. | | Method resolution order: | JSONSkipHook | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from exceptions.Exception: | | __init__(...) | x.__init__(...) initializes x; see help(type(x)) for signature | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __repr__(...) | x.__repr__() <==> repr(x) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class JSONStopProcessing(JSONException) | Can be raised by anyplace, including inside a hook function, to | cause the entire encode or decode process to immediately stop | with an error. | | Method resolution order: | JSONStopProcessing | JSONException | exceptions.Exception | exceptions.BaseException | __builtin__.object | | Data descriptors inherited from JSONException: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from exceptions.Exception: | | __init__(...) | x.__init__(...) initializes x; see help(type(x)) for signature | | ---------------------------------------------------------------------- | Data and other attributes inherited from exceptions.Exception: | | __new__ = | T.__new__(S, ...) -> a new object with type S, a subtype of T | | ---------------------------------------------------------------------- | Methods inherited from exceptions.BaseException: | | __delattr__(...) | x.__delattr__('name') <==> del x.name | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __reduce__(...) | | __repr__(...) | x.__repr__() <==> repr(x) | | __setattr__(...) | x.__setattr__('name', value) <==> x.name = value | | __setstate__(...) | | __str__(...) | x.__str__() <==> str(x) | | __unicode__(...) | | ---------------------------------------------------------------------- | Data descriptors inherited from exceptions.BaseException: | | __dict__ | | args | | message class buffered_stream(__builtin__.object) | A helper class for the JSON parser. | | It allows for reading an input document, while handling some | low-level Unicode issues as well as tracking the current position | in terms of line and column position. | | Methods defined here: | | __getitem__(self, index) | Returns the character at the given index relative to the current position. | | If the index goes beyond the end of the input, or prior to the | start when negative, then '' is returned. | | If the index provided is a slice object, then that range of | characters is returned as a string. Note that a stride value other | than 1 is not supported in the slice. To use a slice, do: | | s = my_stream[ 1:4 ] | | __init__(self, txt='', encoding=None) | | __repr__(self) | | at_eol(self, allow_unicode_eol=True) | Returns True if the current position contains an | end-of-line control character. | | at_ws(self, allow_unicode_whitespace=True) | Returns True if the current position contains a white-space | character. | | clear_saved_position(self) | | peek(self, offset=0) | Returns the character at the current position, or at a | given offset away from the current position. If the position | is beyond the limits of the document size, then an empty | string '' is returned. | | peekstr(self, span=1, offset=0) | Returns one or more characters starting at the current | position, or at a given offset away from the current position, | and continuing for the given span length. If the offset and | span go outside the limit of the current document size, then | the returned string may be shorter than the requested span | length. | | pop(self) | Returns the character at the current position and advances | the position to the next character. At the end of the | document this function returns an empty string. | | pop_identifier(self, match=None) | Pops the sequence of characters at the current position | that match the syntax for a JavaScript identifier. | | pop_if_startswith(self, s) | Pops the sequence of characters if they match the given string. | | See also method: startswith() | | pop_while_in(self, chars) | Pops a sequence of characters at the current position | as long as each of them is in the given set of characters. | | popif(self, testfn) | Just like the pop() function, but only returns the | character if the given predicate test function succeeds. | | popstr(self, span=1, offset=0) | Returns a string of one or more characters starting at the | current position, and advances the position to the following | character after the span. Will not go beyond the end of the | document, so the returned string may be shorter than the | requested span. | | popuntil(self, testfn, maxchars=None) | Just like popwhile() method except the predicate function | should return True to stop the sequence rather than False. | | See also methods: skipuntil() and popwhile() | | popwhile(self, testfn, maxchars=None) | Pops all the characters starting at the current position as | long as each character passes the given predicate function | test. If maxchars a numeric value instead of None then then | no more than that number of characters will be popped | regardless of the predicate test. | | See also methods: skipwhile() and popuntil() | | reset(self) | Clears the state to nothing. | | restore_position(self) | | rewind(self) | Resets the position back to the start of the input text. | | save_position(self) | | set_text(self, txt, encoding=None) | Changes the input text document and rewinds the position to | the start of the new document. | | skip(self, span=1) | Advances the current position by one (or the given number) | of characters. Will not advance beyond the end of the | document. Returns the number of characters skipped. | | skip_to_next_line(self, allow_unicode_eol=True) | Advances the current position to the start of the next | line. Will not advance beyond the end of the file. Note that | the two-character sequence CR+LF is recognized as being just a | single end-of-line marker. | | skipuntil(self, testfn) | Advances the current position until a given predicate test | function succeeds, or the end of the document is reached. | | Returns the actual number of characters skipped. | | The provided test function should take a single unicode | character and return a boolean value, such as: | | lambda c : c == '.' # Skip to next period | | See also methods: skipwhile() and popuntil() | | skipwhile(self, testfn) | Advances the current position until a given predicate test | function fails, or the end of the document is reached. | | Returns the actual number of characters skipped. | | The provided test function should take a single unicode | character and return a boolean value, such as: | | lambda c : c.isdigit() # Skip all digits | | See also methods: skipuntil() and popwhile() | | skipws(self, allow_unicode_whitespace=True) | Advances the current position past all whitespace, or until | the end of the document is reached. | | startswith(self, s) | Determines if the text at the current position starts with | the given string. | | See also method: pop_if_startswith() | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | at_end | Returns True if the position is currently at the end of the | document, of False otherwise. | | at_start | Returns True if the position is currently at the start of | the document, or False otherwise. | | bom | The Unicode Byte-Order Mark (BOM), if any, that was present | at the start of the input text. The returned BOM is a string | of the raw bytes, and is not Unicode-decoded. | | codec | The codec object used to perform Unicode decoding, or None. | | cpos | The current character offset from the start of the document. | | position | The current position (as a position_marker object). | Returns a copy. | | text_context | A short human-readable textual excerpt of the document at | the current position, in English. class decode_state(__builtin__.object) | An internal transient object used during JSON decoding to | record the current parsing state and error messages. | | Methods defined here: | | __init__(self, options=None) | | push_cond(self, behavior_value, message, *args, **kwargs) | Creates an conditional error or warning message. | | The behavior value (from json_options) controls whether | a message will be pushed and whether it is an error | or warning message. | | push_error(self, message, *args, **kwargs) | Create an error. | | push_exception(self, exc) | Add an already-built exception to the error list. | | push_fatal(self, message, *args, **kwargs) | Create a fatal error. | | push_info(self, message, *args, **kwargs) | Create a informational message. | | push_warning(self, message, *args, **kwargs) | Create a warning. | | reset(self) | Clears all errors, statistics, and input text. | | set_input(self, txt, encoding=None) | Initialize the state by setting the input document text. | | update_depth_stats(self, **kwargs) | | update_float_stats(self, float_value, **kwargs) | | update_integer_stats(self, int_value, **kwargs) | | update_negzero_float_stats(self, **kwargs) | | update_negzero_int_stats(self, **kwargs) | | update_string_stats(self, s, **kwargs) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | has_errors | Have any errors been seen already? | | has_fatal | Have any errors been seen already? | | should_stop class decode_statistics(__builtin__.object) | An object that records various statistics about a decoded JSON document. | | Methods defined here: | | __init__(self) | | pretty_description(self, prefix='') | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | num_infinites | Misspelled 'num_infinities' for backwards compatibility | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | double_int_max = 9007199254740991 | | double_int_min = -9007199254740991 | | int16_max = 32767 | | int16_min = -32768 | | int32_max = 2147483647 | | int32_min = -2147483648 | | int64_max = 9223372036854775807 | | int64_min = -9223372036854775808 | | int8_max = 127 | | int8_min = -128 class encode_state(__builtin__.object) | An internal transient object used during JSON encoding to | record the current construction state. | | Methods defined here: | | __eq__(self, other_state) | | __init__(self, jsopts=None, parent=None) | | __lt__(self, other_state) | | append(self, s) | Adds a string to the end of the current JSON document | | combine(self) | Returns the accumulated string and resets the state to empty | | join_substate(self, other_state) | | make_substate(self) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class helpers(__builtin__.object) | A set of utility functions. | | Static methods defined here: | | auto_detect_encoding(s) | Takes a string (or byte array) and tries to determine the Unicode encoding it is in. | | Returns the encoding name, as a string. | | char_is_identifier_leader(c) | Determines if the character may be the first character of a | JavaScript identifier. | | char_is_identifier_tail(c) | Determines if the character may be part of a JavaScript | identifier. | | char_is_json_eol(c) | Determines if the given character is a JSON line separator | | char_is_json_ws(c) | Determines if the given character is a JSON white-space character | | char_is_unicode_eol(c) | Determines if the given character is a Unicode line or | paragraph separator. These correspond to CR and LF as well as | Unicode characters in the Zl or Zp categories. | | char_is_unicode_ws(c) | Determines if the given character is a Unicode space character | | decode_binary(binarystring) | Decodes a binary string into it's integer value. | | decode_hex(hexstring) | Decodes a hexadecimal string into it's integer value. | | decode_octal(octalstring) | Decodes an octal string into it's integer value. | | extend_and_flatten_list_with_sep(orig_seq, extension_seq, separator='') | | format_timedelta_iso(td) | Encodes a datetime.timedelta into ISO-8601 Time Period format. | | is_binary_digit(c) | Determines if the given character is a valid binary digit (0 or 1). | | is_hex_digit(c) | Determines if the given character is a valid hexadecimal digit (0-9, a-f, A-F). | | is_infinite(n) | Is the number infinite? | | is_nan(n) | Is the number a NaN (not-a-number)? | | is_negzero(n) | Is the number value a negative zero? | | is_octal_digit(c) | Determines if the given character is a valid octal digit (0-7). | | isnumbertype(obj) | Is the object of a Python number type (excluding complex)? | | isstringtype(obj) | Is the object of a Python string type? | | lookup_codec(encoding) | Wrapper around codecs.lookup(). | | Returns None if codec not found, rather than raising a LookupError. | | make_raw_bytes(byte_list) | Constructs a byte array (bytes in Python 3, str in Python 2) from a list of byte values (0-255). | | make_surrogate_pair(codepoint) | Given a Unicode codepoint (int) returns a 2-tuple of surrogate codepoints. | | safe_unichr(codepoint) | Just like Python's unichr() but works in narrow-Unicode Pythons. | | strip_format_control_chars(txt) | Filters out all Unicode format control characters from the string. | | ECMAScript permits any Unicode "format control characters" to | appear at any place in the source code. They are to be | ignored as if they are not there before any other lexical | tokenization occurs. Note that JSON does not allow them, | except within string literals. | | * Ref. ECMAScript section 7.1. | * http://en.wikipedia.org/wiki/Unicode_control_characters | | There are dozens of Format Control Characters, for example: | U+00AD SOFT HYPHEN | U+200B ZERO WIDTH SPACE | U+2060 WORD JOINER | | surrogate_pair_as_unicode(c1, c2) | Takes a pair of unicode surrogates and returns the equivalent unicode character. | | The input pair must be a surrogate pair, with c1 in the range | U+D800 to U+DBFF and c2 in the range U+DC00 to U+DFFF. | | unicode_as_surrogate_pair(c) | Takes a single unicode character and returns a sequence of surrogate pairs. | | The output of this function is a tuple consisting of one or two unicode | characters, such that if the input character is outside the BMP range | then the output is a two-character surrogate pair representing that character. | | If the input character is inside the BMP then the output tuple will have | just a single character...the same one. | | unicode_decode(txt, encoding=None) | Takes a string (or byte array) and tries to convert it to a Unicode string. | | Returns a named tuple: (string, codec, bom) | | The 'encoding' argument, if supplied, should either the name of | a character encoding, or an instance of codecs.CodecInfo. If | the encoding argument is None or "auto" then the encoding is | automatically determined, if possible. | | Any BOM (Byte Order Mark) that is found at the beginning of the | input will be stripped off and placed in the 'bom' portion of | the returned value. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | always_use_custom_codecs = False | | hexdigits = '0123456789ABCDEFabcdef' | | javascript_reserved_words = frozenset(['break', 'case', 'catch', 'clas... | | maxunicode = 1114111 | | octaldigits = '01234567' | | sys = | | unsafe_string_chars = u'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x... class json_int(__builtin__.long) | A subclass of the Python int/long that remembers its format (hex,octal,etc). | | Initialize it the same as an int, but also accepts an additional keyword | argument 'number_format' which should be one of the NUMBER_FORMAT_* values. | | n = json_int( x[, base, number_format=NUMBER_FORMAT_DECIMAL] ) | | Method resolution order: | json_int | __builtin__.long | __builtin__.object | | Methods defined here: | | json_format(self) | Returns the integer value formatted as a JSON literal | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(cls, *args, **kwargs) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | number_format | The original radix format of the number | | ---------------------------------------------------------------------- | Methods inherited from __builtin__.long: | | __abs__(...) | x.__abs__() <==> abs(x) | | __add__(...) | x.__add__(y) <==> x+y | | __and__(...) | x.__and__(y) <==> x&y | | __cmp__(...) | x.__cmp__(y) <==> cmp(x,y) | | __coerce__(...) | x.__coerce__(y) <==> coerce(x, y) | | __div__(...) | x.__div__(y) <==> x/y | | __divmod__(...) | x.__divmod__(y) <==> divmod(x, y) | | __float__(...) | x.__float__() <==> float(x) | | __floordiv__(...) | x.__floordiv__(y) <==> x//y | | __format__(...) | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getnewargs__(...) | | __hash__(...) | x.__hash__() <==> hash(x) | | __hex__(...) | x.__hex__() <==> hex(x) | | __index__(...) | x[y:z] <==> x[y.__index__():z.__index__()] | | __int__(...) | x.__int__() <==> int(x) | | __invert__(...) | x.__invert__() <==> ~x | | __long__(...) | x.__long__() <==> long(x) | | __lshift__(...) | x.__lshift__(y) <==> x< x%y | | __mul__(...) | x.__mul__(y) <==> x*y | | __neg__(...) | x.__neg__() <==> -x | | __nonzero__(...) | x.__nonzero__() <==> x != 0 | | __oct__(...) | x.__oct__() <==> oct(x) | | __or__(...) | x.__or__(y) <==> x|y | | __pos__(...) | x.__pos__() <==> +x | | __pow__(...) | x.__pow__(y[, z]) <==> pow(x, y[, z]) | | __radd__(...) | x.__radd__(y) <==> y+x | | __rand__(...) | x.__rand__(y) <==> y&x | | __rdiv__(...) | x.__rdiv__(y) <==> y/x | | __rdivmod__(...) | x.__rdivmod__(y) <==> divmod(y, x) | | __repr__(...) | x.__repr__() <==> repr(x) | | __rfloordiv__(...) | x.__rfloordiv__(y) <==> y//x | | __rlshift__(...) | x.__rlshift__(y) <==> y< y%x | | __rmul__(...) | x.__rmul__(y) <==> y*x | | __ror__(...) | x.__ror__(y) <==> y|x | | __rpow__(...) | y.__rpow__(x[, z]) <==> pow(x, y[, z]) | | __rrshift__(...) | x.__rrshift__(y) <==> y>>x | | __rshift__(...) | x.__rshift__(y) <==> x>>y | | __rsub__(...) | x.__rsub__(y) <==> y-x | | __rtruediv__(...) | x.__rtruediv__(y) <==> y/x | | __rxor__(...) | x.__rxor__(y) <==> y^x | | __sizeof__(...) | Returns size in memory, in bytes | | __str__(...) | x.__str__() <==> str(x) | | __sub__(...) | x.__sub__(y) <==> x-y | | __truediv__(...) | x.__truediv__(y) <==> x/y | | __trunc__(...) | Truncating an Integral returns itself. | | __xor__(...) | x.__xor__(y) <==> x^y | | bit_length(...) | long.bit_length() -> int or long | | Number of bits necessary to represent self in binary. | >>> bin(37L) | '0b100101' | >>> (37L).bit_length() | 6 | | conjugate(...) | Returns self, the complex conjugate of any long. | | ---------------------------------------------------------------------- | Data descriptors inherited from __builtin__.long: | | denominator | the denominator of a rational number in lowest terms | | imag | the imaginary part of a complex number | | numerator | the numerator of a rational number in lowest terms | | real | the real part of a complex number class json_options(__builtin__.object) | Options to determine how strict the decoder or encoder should be. | | Methods defined here: | | __eq__ = behaviors_eq(self, other) | Determines if two options objects are equivalent. | | __init__(self, **kwargs) | Set JSON encoding and decoding options. | | If 'strict' is set to True, then only strictly-conforming JSON | output will be produced. Note that this means that some types | of values may not be convertable and will result in a | JSONEncodeError exception. | | If 'compactly' is set to True, then the resulting string will | have all extraneous white space removed; if False then the | string will be "pretty printed" with whitespace and indentation | added to make it more readable. | | If 'escape_unicode' is set to True, then all non-ASCII characters | will be represented as a unicode escape sequence; if False then | the actual real unicode character will be inserted if possible. | | The 'escape_unicode' can also be a function, which when called | with a single argument of a unicode character will return True | if the character should be escaped or False if it should not. | | allow_all_numeric_signs(self, _name='all_numeric_signs', _value='allow') | Set behavior all_numeric_signs to allow. | | allow_any_type_at_start(self, _name='any_type_at_start', _value='allow') | Set behavior any_type_at_start to allow. | | allow_binary_numbers(self, _name='binary_numbers', _value='allow') | Set behavior binary_numbers to allow. | | allow_bom(self, _name='bom', _value='allow') | Set behavior bom to allow. | | allow_comments(self, _name='comments', _value='allow') | Set behavior comments to allow. | | allow_control_char_in_string(self, _name='control_char_in_string', _value='allow') | Set behavior control_char_in_string to allow. | | allow_duplicate_keys(self, _name='duplicate_keys', _value='allow') | Set behavior duplicate_keys to allow. | | allow_extended_unicode_escapes(self, _name='extended_unicode_escapes', _value='allow') | Set behavior extended_unicode_escapes to allow. | | allow_format_control_chars(self, _name='format_control_chars', _value='allow') | Set behavior format_control_chars to allow. | | allow_hex_numbers(self, _name='hex_numbers', _value='allow') | Set behavior hex_numbers to allow. | | allow_identifier_keys(self, _name='identifier_keys', _value='allow') | Set behavior identifier_keys to allow. | | allow_initial_decimal_point(self, _name='initial_decimal_point', _value='allow') | Set behavior initial_decimal_point to allow. | | allow_js_string_escapes(self, _name='js_string_escapes', _value='allow') | Set behavior js_string_escapes to allow. | | allow_leading_zeros(self, _name='leading_zeros', _value='allow') | Set behavior leading_zeros to allow. | | allow_non_numbers(self, _name='non_numbers', _value='allow') | Set behavior non_numbers to allow. | | allow_non_portable(self, _name='non_portable', _value='allow') | Set behavior non_portable to allow. | | allow_nonescape_characters(self, _name='nonescape_characters', _value='allow') | Set behavior nonescape_characters to allow. | | allow_nonstring_keys(self, _name='nonstring_keys', _value='allow') | Set behavior nonstring_keys to allow. | | allow_octal_numbers(self, _name='octal_numbers', _value='allow') | Set behavior octal_numbers to allow. | | allow_omitted_array_elements(self, _name='omitted_array_elements', _value='allow') | Set behavior omitted_array_elements to allow. | | allow_single_quoted_strings(self, _name='single_quoted_strings', _value='allow') | Set behavior single_quoted_strings to allow. | | allow_trailing_comma(self, _name='trailing_comma', _value='allow') | Set behavior trailing_comma to allow. | | allow_trailing_decimal_point(self, _name='trailing_decimal_point', _value='allow') | Set behavior trailing_decimal_point to allow. | | allow_undefined_values(self, _name='undefined_values', _value='allow') | Set behavior undefined_values to allow. | | allow_unicode_whitespace(self, _name='unicode_whitespace', _value='allow') | Set behavior unicode_whitespace to allow. | | allow_zero_byte(self, _name='zero_byte', _value='allow') | Set behavior zero_byte to allow. | | copy(self) | | copy_from(self, other) | | describe_behavior(self, name) | Returns documentation about a given behavior. | | forbid_all_numeric_signs(self, _name='all_numeric_signs', _value='forbid') | Set behavior all_numeric_signs to forbid. | | forbid_any_type_at_start(self, _name='any_type_at_start', _value='forbid') | Set behavior any_type_at_start to forbid. | | forbid_binary_numbers(self, _name='binary_numbers', _value='forbid') | Set behavior binary_numbers to forbid. | | forbid_bom(self, _name='bom', _value='forbid') | Set behavior bom to forbid. | | forbid_comments(self, _name='comments', _value='forbid') | Set behavior comments to forbid. | | forbid_control_char_in_string(self, _name='control_char_in_string', _value='forbid') | Set behavior control_char_in_string to forbid. | | forbid_duplicate_keys(self, _name='duplicate_keys', _value='forbid') | Set behavior duplicate_keys to forbid. | | forbid_extended_unicode_escapes(self, _name='extended_unicode_escapes', _value='forbid') | Set behavior extended_unicode_escapes to forbid. | | forbid_format_control_chars(self, _name='format_control_chars', _value='forbid') | Set behavior format_control_chars to forbid. | | forbid_hex_numbers(self, _name='hex_numbers', _value='forbid') | Set behavior hex_numbers to forbid. | | forbid_identifier_keys(self, _name='identifier_keys', _value='forbid') | Set behavior identifier_keys to forbid. | | forbid_initial_decimal_point(self, _name='initial_decimal_point', _value='forbid') | Set behavior initial_decimal_point to forbid. | | forbid_js_string_escapes(self, _name='js_string_escapes', _value='forbid') | Set behavior js_string_escapes to forbid. | | forbid_leading_zeros(self, _name='leading_zeros', _value='forbid') | Set behavior leading_zeros to forbid. | | forbid_non_numbers(self, _name='non_numbers', _value='forbid') | Set behavior non_numbers to forbid. | | forbid_non_portable(self, _name='non_portable', _value='forbid') | Set behavior non_portable to forbid. | | forbid_nonescape_characters(self, _name='nonescape_characters', _value='forbid') | Set behavior nonescape_characters to forbid. | | forbid_nonstring_keys(self, _name='nonstring_keys', _value='forbid') | Set behavior nonstring_keys to forbid. | | forbid_octal_numbers(self, _name='octal_numbers', _value='forbid') | Set behavior octal_numbers to forbid. | | forbid_omitted_array_elements(self, _name='omitted_array_elements', _value='forbid') | Set behavior omitted_array_elements to forbid. | | forbid_single_quoted_strings(self, _name='single_quoted_strings', _value='forbid') | Set behavior single_quoted_strings to forbid. | | forbid_trailing_comma(self, _name='trailing_comma', _value='forbid') | Set behavior trailing_comma to forbid. | | forbid_trailing_decimal_point(self, _name='trailing_decimal_point', _value='forbid') | Set behavior trailing_decimal_point to forbid. | | forbid_undefined_values(self, _name='undefined_values', _value='forbid') | Set behavior undefined_values to forbid. | | forbid_unicode_whitespace(self, _name='unicode_whitespace', _value='forbid') | Set behavior unicode_whitespace to forbid. | | forbid_zero_byte(self, _name='zero_byte', _value='forbid') | Set behavior zero_byte to forbid. | | get_behavior(self, name) | Returns the value for a given behavior | | indentation_for_level(self, level=0) | Returns a whitespace string used for indenting. | | is_all(self, value) | Determines if all the behaviors have the given value. | | make_decimal(self, s, sign='+') | Converts a string into a decimal or float value. | | make_float(self, s, sign='+') | Converts a string into a float or decimal value. | | make_int(self, s, sign=None, number_format='decimal') | Makes an integer value according to the current options. | | First argument should be a string representation of the number, | or an integer. | | Returns a number value, which could be an int, float, or decimal. | | reset_to_defaults(self) | | set_all(self, value) | Changes all behaviors to have the given value. | | set_all_allow(self, _value='allow') | Set all behaviors to value allow. | | set_all_forbid(self, _value='forbid') | Set all behaviors to value forbid. | | set_all_warn(self, _value='warn') | Set all behaviors to value warn. | | set_behavior(self, name, value) | Changes the value for a given behavior | | set_indent(self, num_spaces, tab_width=0, limit=None) | Changes the indentation properties when outputting JSON in non-compact mode. | | 'num_spaces' is the number of spaces to insert for each level | of indentation, which defaults to 2. | | 'tab_width', if not 0, is the number of spaces which is equivalent | to one tab character. Tabs will be output where possible rather | than runs of spaces. | | 'limit', if not None, is the maximum indentation level after | which no further indentation will be output. | | spaces_to_next_indent_level(self, min_spaces=1, subtract=0) | | suppress_warnings(self) | | warn_all_numeric_signs(self, _name='all_numeric_signs', _value='warn') | Set behavior all_numeric_signs to warn. | | warn_any_type_at_start(self, _name='any_type_at_start', _value='warn') | Set behavior any_type_at_start to warn. | | warn_binary_numbers(self, _name='binary_numbers', _value='warn') | Set behavior binary_numbers to warn. | | warn_bom(self, _name='bom', _value='warn') | Set behavior bom to warn. | | warn_comments(self, _name='comments', _value='warn') | Set behavior comments to warn. | | warn_control_char_in_string(self, _name='control_char_in_string', _value='warn') | Set behavior control_char_in_string to warn. | | warn_duplicate_keys(self, _name='duplicate_keys', _value='warn') | Set behavior duplicate_keys to warn. | | warn_extended_unicode_escapes(self, _name='extended_unicode_escapes', _value='warn') | Set behavior extended_unicode_escapes to warn. | | warn_format_control_chars(self, _name='format_control_chars', _value='warn') | Set behavior format_control_chars to warn. | | warn_hex_numbers(self, _name='hex_numbers', _value='warn') | Set behavior hex_numbers to warn. | | warn_identifier_keys(self, _name='identifier_keys', _value='warn') | Set behavior identifier_keys to warn. | | warn_initial_decimal_point(self, _name='initial_decimal_point', _value='warn') | Set behavior initial_decimal_point to warn. | | warn_js_string_escapes(self, _name='js_string_escapes', _value='warn') | Set behavior js_string_escapes to warn. | | warn_leading_zeros(self, _name='leading_zeros', _value='warn') | Set behavior leading_zeros to warn. | | warn_non_numbers(self, _name='non_numbers', _value='warn') | Set behavior non_numbers to warn. | | warn_non_portable(self, _name='non_portable', _value='warn') | Set behavior non_portable to warn. | | warn_nonescape_characters(self, _name='nonescape_characters', _value='warn') | Set behavior nonescape_characters to warn. | | warn_nonstring_keys(self, _name='nonstring_keys', _value='warn') | Set behavior nonstring_keys to warn. | | warn_octal_numbers(self, _name='octal_numbers', _value='warn') | Set behavior octal_numbers to warn. | | warn_omitted_array_elements(self, _name='omitted_array_elements', _value='warn') | Set behavior omitted_array_elements to warn. | | warn_single_quoted_strings(self, _name='single_quoted_strings', _value='warn') | Set behavior single_quoted_strings to warn. | | warn_trailing_comma(self, _name='trailing_comma', _value='warn') | Set behavior trailing_comma to warn. | | warn_trailing_decimal_point(self, _name='trailing_decimal_point', _value='warn') | Set behavior trailing_decimal_point to warn. | | warn_undefined_values(self, _name='undefined_values', _value='warn') | Set behavior undefined_values to warn. | | warn_unicode_whitespace(self, _name='unicode_whitespace', _value='warn') | Set behavior unicode_whitespace to warn. | | warn_zero_byte(self, _name='zero_byte', _value='warn') | Set behavior zero_byte to warn. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | all_behaviors | Returns the names of all known behaviors. | | all_numeric_signs | Numbers may be prefixed by any '+' and '-', e.g., +4, -+-+77 | | allow_behaviors | Return the set of behaviors with the value allow. | | allow_or_warn_behaviors | Returns the set of all behaviors that are not forbidden (i.e., are allowed or warned). | | any_type_at_start | A JSON document may start with any type, not just arrays or objects | | binary_numbers | Binary numbers, e.g., 0b1001 | | bom | A JSON document may start with a Unicode BOM (Byte Order Mark) | | comments | JavaScript comments, both /*...*/ and //... styles | | control_char_in_string | Strings may contain raw control characters without \u-escaping | | duplicate_keys | Objects may have repeated keys | | encode_enum_as | The strategy for encoding Python Enum values. | | extended_unicode_escapes | Extended Unicode escape sequence \u{..} for non-BMP characters | | forbid_behaviors | Return the set of behaviors with the value forbid. | | format_control_chars | Unicode "format control characters" may appear in the input | | hex_numbers | Hexadecimal numbers, e.g., 0x1f | | identifier_keys | JavaScript identifiers are converted to strings when used as object keys | | inf | The numeric value Infinity, either a float or a decimal. | | initial_decimal_point | Floating-point numbers may start with a decimal point (no units digit) | | is_all_allow | Determines if all the behaviors have the value allow. | | is_all_forbid | Determines if all the behaviors have the value forbid. | | is_all_warn | Determines if all the behaviors have the value warn. | | is_allow_all_numeric_signs | Allow Numbers may be prefixed by any '+' and '-', e.g., +4, -+-+77 | | is_allow_any_type_at_start | Allow A JSON document may start with any type, not just arrays or objects | | is_allow_binary_numbers | Allow Binary numbers, e.g., 0b1001 | | is_allow_bom | Allow A JSON document may start with a Unicode BOM (Byte Order Mark) | | is_allow_comments | Allow JavaScript comments, both /*...*/ and //... styles | | is_allow_control_char_in_string | Allow Strings may contain raw control characters without \u-escaping | | is_allow_duplicate_keys | Allow Objects may have repeated keys | | is_allow_extended_unicode_escapes | Allow Extended Unicode escape sequence \u{..} for non-BMP characters | | is_allow_format_control_chars | Allow Unicode "format control characters" may appear in the input | | is_allow_hex_numbers | Allow Hexadecimal numbers, e.g., 0x1f | | is_allow_identifier_keys | Allow JavaScript identifiers are converted to strings when used as object keys | | is_allow_initial_decimal_point | Allow Floating-point numbers may start with a decimal point (no units digit) | | is_allow_js_string_escapes | Allow All JavaScript character \-escape sequences may be in strings | | is_allow_leading_zeros | Allow Numbers may have leading zeros | | is_allow_non_numbers | Allow Non-numbers may be used, such as NaN or Infinity | | is_allow_non_portable | Allow Anything technically valid but likely to cause data portablibity issues | | is_allow_nonescape_characters | Allow Unknown character \-escape sequences stand for that character (\Q -> 'Q') | | is_allow_nonstring_keys | Allow Value types other than strings (or identifiers) may be used as object keys | | is_allow_octal_numbers | Allow New-style octal numbers, e.g., 0o731 (see leading-zeros for legacy octals) | | is_allow_omitted_array_elements | Allow Arrays may have omitted/elided elements, e.g., [1,,3] == [1,undefined,3] | | is_allow_single_quoted_strings | Allow Strings may be delimited with both double (") and single (') quotation marks | | is_allow_trailing_comma | Allow A final comma may end the list of array or object members | | is_allow_trailing_decimal_point | Allow Floating-point number may end with a decimal point and no following fractional digits | | is_allow_undefined_values | Allow The JavaScript 'undefined' value may be used | | is_allow_unicode_whitespace | Allow Treat any Unicode whitespace character as valid whitespace | | is_allow_zero_byte | Allow Strings may contain U+0000, which may not be safe for C-based programs | | is_forbid_all_numeric_signs | Forbid Numbers may be prefixed by any '+' and '-', e.g., +4, -+-+77 | | is_forbid_any_type_at_start | Forbid A JSON document may start with any type, not just arrays or objects | | is_forbid_binary_numbers | Forbid Binary numbers, e.g., 0b1001 | | is_forbid_bom | Forbid A JSON document may start with a Unicode BOM (Byte Order Mark) | | is_forbid_comments | Forbid JavaScript comments, both /*...*/ and //... styles | | is_forbid_control_char_in_string | Forbid Strings may contain raw control characters without \u-escaping | | is_forbid_duplicate_keys | Forbid Objects may have repeated keys | | is_forbid_extended_unicode_escapes | Forbid Extended Unicode escape sequence \u{..} for non-BMP characters | | is_forbid_format_control_chars | Forbid Unicode "format control characters" may appear in the input | | is_forbid_hex_numbers | Forbid Hexadecimal numbers, e.g., 0x1f | | is_forbid_identifier_keys | Forbid JavaScript identifiers are converted to strings when used as object keys | | is_forbid_initial_decimal_point | Forbid Floating-point numbers may start with a decimal point (no units digit) | | is_forbid_js_string_escapes | Forbid All JavaScript character \-escape sequences may be in strings | | is_forbid_leading_zeros | Forbid Numbers may have leading zeros | | is_forbid_non_numbers | Forbid Non-numbers may be used, such as NaN or Infinity | | is_forbid_non_portable | Forbid Anything technically valid but likely to cause data portablibity issues | | is_forbid_nonescape_characters | Forbid Unknown character \-escape sequences stand for that character (\Q -> 'Q') | | is_forbid_nonstring_keys | Forbid Value types other than strings (or identifiers) may be used as object keys | | is_forbid_octal_numbers | Forbid New-style octal numbers, e.g., 0o731 (see leading-zeros for legacy octals) | | is_forbid_omitted_array_elements | Forbid Arrays may have omitted/elided elements, e.g., [1,,3] == [1,undefined,3] | | is_forbid_single_quoted_strings | Forbid Strings may be delimited with both double (") and single (') quotation marks | | is_forbid_trailing_comma | Forbid A final comma may end the list of array or object members | | is_forbid_trailing_decimal_point | Forbid Floating-point number may end with a decimal point and no following fractional digits | | is_forbid_undefined_values | Forbid The JavaScript 'undefined' value may be used | | is_forbid_unicode_whitespace | Forbid Treat any Unicode whitespace character as valid whitespace | | is_forbid_zero_byte | Forbid Strings may contain U+0000, which may not be safe for C-based programs | | is_warn_all_numeric_signs | Warn Numbers may be prefixed by any '+' and '-', e.g., +4, -+-+77 | | is_warn_any_type_at_start | Warn A JSON document may start with any type, not just arrays or objects | | is_warn_binary_numbers | Warn Binary numbers, e.g., 0b1001 | | is_warn_bom | Warn A JSON document may start with a Unicode BOM (Byte Order Mark) | | is_warn_comments | Warn JavaScript comments, both /*...*/ and //... styles | | is_warn_control_char_in_string | Warn Strings may contain raw control characters without \u-escaping | | is_warn_duplicate_keys | Warn Objects may have repeated keys | | is_warn_extended_unicode_escapes | Warn Extended Unicode escape sequence \u{..} for non-BMP characters | | is_warn_format_control_chars | Warn Unicode "format control characters" may appear in the input | | is_warn_hex_numbers | Warn Hexadecimal numbers, e.g., 0x1f | | is_warn_identifier_keys | Warn JavaScript identifiers are converted to strings when used as object keys | | is_warn_initial_decimal_point | Warn Floating-point numbers may start with a decimal point (no units digit) | | is_warn_js_string_escapes | Warn All JavaScript character \-escape sequences may be in strings | | is_warn_leading_zeros | Warn Numbers may have leading zeros | | is_warn_non_numbers | Warn Non-numbers may be used, such as NaN or Infinity | | is_warn_non_portable | Warn Anything technically valid but likely to cause data portablibity issues | | is_warn_nonescape_characters | Warn Unknown character \-escape sequences stand for that character (\Q -> 'Q') | | is_warn_nonstring_keys | Warn Value types other than strings (or identifiers) may be used as object keys | | is_warn_octal_numbers | Warn New-style octal numbers, e.g., 0o731 (see leading-zeros for legacy octals) | | is_warn_omitted_array_elements | Warn Arrays may have omitted/elided elements, e.g., [1,,3] == [1,undefined,3] | | is_warn_single_quoted_strings | Warn Strings may be delimited with both double (") and single (') quotation marks | | is_warn_trailing_comma | Warn A final comma may end the list of array or object members | | is_warn_trailing_decimal_point | Warn Floating-point number may end with a decimal point and no following fractional digits | | is_warn_undefined_values | Warn The JavaScript 'undefined' value may be used | | is_warn_unicode_whitespace | Warn Treat any Unicode whitespace character as valid whitespace | | is_warn_zero_byte | Warn Strings may contain U+0000, which may not be safe for C-based programs | | js_string_escapes | All JavaScript character \-escape sequences may be in strings | | leading_zero_radix | The radix to be used for numbers with leading zeros. 8 or 10 | | leading_zero_radix_as_word | | leading_zeros | Numbers may have leading zeros | | nan | The numeric value NaN, either a float or a decimal. | | neginf | The numeric value -Infinity, either a float or a decimal. | | negzero_float | The numeric value -0.0, either a float or a decimal. | | non_numbers | Non-numbers may be used, such as NaN or Infinity | | non_portable | Anything technically valid but likely to cause data portablibity issues | | nonescape_characters | Unknown character \-escape sequences stand for that character (\Q -> 'Q') | | nonstring_keys | Value types other than strings (or identifiers) may be used as object keys | | octal_numbers | New-style octal numbers, e.g., 0o731 (see leading-zeros for legacy octals) | | omitted_array_elements | Arrays may have omitted/elided elements, e.g., [1,,3] == [1,undefined,3] | | single_quoted_strings | Strings may be delimited with both double (") and single (') quotation marks | | sort_keys | The method used to sort dictionary keys when encoding JSON | | strictness | | trailing_comma | A final comma may end the list of array or object members | | trailing_decimal_point | Floating-point number may end with a decimal point and no following fractional digits | | undefined_values | The JavaScript 'undefined' value may be used | | unicode_whitespace | Treat any Unicode whitespace character as valid whitespace | | values | Set of possible behavior values | | warn_behaviors | Return the set of behaviors with the value warn. | | zero_byte | Strings may contain U+0000, which may not be safe for C-based programs | | zero_float | The numeric value 0.0, either a float or a decimal. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __metaclass__ = | Meta class used to establish a set of "behavior" options. | | Classes that use this meta class must defined a class-level | variable called '_behaviors' that is a list of tuples, each of | which describes one behavior and is like: (behavior_name, | documentation). Also define a second class-level variable called | '_behavior_values' which is a list of the permitted values for | each behavior, each being strings. | | For each behavior (e.g., pretty), and for each value (e.g., | yes) the following methods/properties will be created: | | * pretty - value of 'pretty' behavior (read-write) | * ispretty_yes - returns True if 'pretty' is 'yes' | | For each value (e.g., pink) the following methods/properties | will be created: | | * all_behaviors - set of all behaviors (read-only) | * pink_behaviors - set of behaviors with value of 'pink' (read-only) | * set_all('pink') | * set_all_pink() - set all behaviors to value of 'pink' class jsonlint(__builtin__.object) | This class contains most of the logic for the "jsonlint" command. | | You generally create an instance of this class, to defined the | program's environment, and then call the main() method. A simple | wrapper to turn this into a script might be: | | import sys, demjson | if __name__ == '__main__': | lint = demjson.jsonlint( sys.argv[0] ) | return lint.main( sys.argv[1:] ) | | Methods defined here: | | __init__(self, program_name='jsonlint', stdin=None, stdout=None, stderr=None) | Create an instance of a "jsonlint" program. | | You can optionally pass options to define the program's environment: | | * program_name - the name of the program, usually sys.argv[0] | * stdin - the file object to use for input, default sys.stdin | * stdout - the file object to use for outut, default sys.stdout | * stderr - the file object to use for error output, default sys.stderr | | After creating an instance, you typically call the main() method. | | main(self, argv) | The main routine for program "jsonlint". | | Should be called with sys.argv[1:] as its sole argument. | | Note sys.argv[0] which normally contains the program name | should not be passed to main(); instead this class itself | is initialized with sys.argv[0]. | | Use "--help" for usage syntax, or consult the 'usage' member. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | usage | A multi-line string containing the program usage instructions. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | SUCCESS_FAIL = 'E' | | SUCCESS_OK = 'OK' | | SUCCESS_WARNING = 'W' class position_marker(__builtin__.object) | A position marks a specific place in a text document. | It consists of the following attributes: | | * line - The line number, starting at 1 | * column - The column on the line, starting at 0 | * char_position - The number of characters from the start of | the document, starting at 0 | * text_after - (optional) a short excerpt of the text of | document starting at the current position | | Lines are separated by any Unicode line separator character. As an | exception a CR+LF character pair is treated as being a single line | separator demarcation. | | Columns are simply a measure of the number of characters after the | start of a new line, starting at 0. Visual effects caused by | Unicode characters such as combining characters, bidirectional | text, zero-width characters and so on do not affect the | computation of the column regardless of visual appearance. | | The char_position is a count of the number of characters since the | beginning of the document, starting at 0. As used within the | buffered_stream class, if the document starts with a Unicode Byte | Order Mark (BOM), the BOM prefix is NOT INCLUDED in the count. | | Methods defined here: | | __init__(self, offset=0, line=1, column=0, text_after=None) | | __repr__(self) | | __str__(self) | Same as the describe() function. | | advance(self, s) | Advance the position from its current place according to | the given string of characters. | | copy(self) | Create a copy of the position object. | | describe(self, show_text=True) | Returns a human-readable description of the position, in English. | | rewind(self) | Set the position to the start of the document. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) | | at_end | Returns True if the position is at the end of the document. | | This property must be set by the user. | | at_start | Returns True if the position is at the start of the document. | | char_position | The current character offset from the beginning of the | document, starts at 0. | | column | The current character column from the beginning of the | document, starts at 0. | | line | The current line within the document, starts at 1. | | text_after | Returns a textual excerpt starting at the current position. | | This property must be set by the user. class utf32(codecs.CodecInfo) | Unicode UTF-32 and UCS4 encoding/decoding support. | | This is for older Pythons whch did not have UTF-32 codecs. | | JSON requires that all JSON implementations must support the | UTF-32 encoding (as well as UTF-8 and UTF-16). But earlier | versions of Python did not provide a UTF-32 codec, so we must | implement UTF-32 ourselves in case we need it. | | See http://en.wikipedia.org/wiki/UTF-32 | | Method resolution order: | utf32 | codecs.CodecInfo | __builtin__.tuple | __builtin__.object | | Static methods defined here: | | decode(obj, errors='strict', endianness=None) | Decodes a UTF-32 byte string into a Unicode string. | | Returns tuple (bytearray, num_bytes) | | The errors argument shold be one of 'strict', 'ignore', | 'replace', 'backslashreplace', or 'xmlcharrefreplace'. | | The endianness should either be None (for auto-guessing), or a | word that starts with 'B' (big) or 'L' (little). | | Will detect a Byte-Order Mark. If a BOM is found and endianness | is also set, then the two must match. | | If neither a BOM is found nor endianness is set, then big | endian order is assumed. | | encode(obj, errors='strict', endianness=None, include_bom=True) | Encodes a Unicode string into a UTF-32 encoded byte string. | | Returns a tuple: (bytearray, num_chars) | | The errors argument should be one of 'strict', 'ignore', or 'replace'. | | The endianness should be one of: | * 'B', '>', or 'big' -- Big endian | * 'L', '<', or 'little' -- Little endien | * None -- Default, from sys.byteorder | | If include_bom is true a Byte-Order Mark will be written to | the beginning of the string, otherwise it will be omitted. | | lookup(name) | A standard Python codec lookup function for UCS4/UTF32. | | If if recognizes an encoding name it returns a CodecInfo | structure which contains the various encode and decoder | functions to use. | | utf32be_decode(obj, errors='strict') | Decodes a UTF-32BE (big endian) byte string into a Unicode string. | | utf32be_encode(obj, errors='strict', include_bom=False) | Encodes a Unicode string into a UTF-32BE (big endian) encoded byte string. | | utf32le_decode(obj, errors='strict') | Decodes a UTF-32LE (little endian) byte string into a Unicode string. | | utf32le_encode(obj, errors='strict', include_bom=False) | Encodes a Unicode string into a UTF-32LE (little endian) encoded byte string. | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | BOM_UTF32_BE = '\x00\x00\xfe\xff' | | BOM_UTF32_LE = '\xff\xfe\x00\x00' | | ---------------------------------------------------------------------- | Methods inherited from codecs.CodecInfo: | | __repr__(self) | | ---------------------------------------------------------------------- | Static methods inherited from codecs.CodecInfo: | | __new__(cls, encode, decode, streamreader=None, streamwriter=None, incrementalencoder=None, incrementaldecoder=None, name=None) | | ---------------------------------------------------------------------- | Data descriptors inherited from codecs.CodecInfo: | | __dict__ | dictionary for instance variables (if defined) | | ---------------------------------------------------------------------- | Methods inherited from __builtin__.tuple: | | __add__(...) | x.__add__(y) <==> x+y | | __contains__(...) | x.__contains__(y) <==> y in x | | __eq__(...) | x.__eq__(y) <==> x==y | | __ge__(...) | x.__ge__(y) <==> x>=y | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getnewargs__(...) | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | Use of negative indices is not supported. | | __gt__(...) | x.__gt__(y) <==> x>y | | __hash__(...) | x.__hash__() <==> hash(x) | | __iter__(...) | x.__iter__() <==> iter(x) | | __le__(...) | x.__le__(y) <==> x<=y | | __len__(...) | x.__len__() <==> len(x) | | __lt__(...) | x.__lt__(y) <==> x x*n | | __ne__(...) | x.__ne__(y) <==> x!=y | | __rmul__(...) | x.__rmul__(n) <==> n*x | | __sizeof__(...) | T.__sizeof__() -- size of T in memory, in bytes | | count(...) | T.count(value) -> integer -- return number of occurrences of value | | index(...) | T.index(value, [start, [stop]]) -> integer -- return first index of value. | Raises ValueError if the value is not present. FUNCTIONS decode(txt, encoding=None, **kwargs) Decodes a JSON-encoded string into a Python object. == Optional arguments == * 'encoding' (string, default None) This argument provides a hint regarding the character encoding that the input text is assumed to be in (if it is not already a unicode string type). If set to None then autodetection of the encoding is attempted (see discussion above). Otherwise this argument should be the name of a registered codec (see the standard 'codecs' module). * 'strict' (Boolean, default False) If 'strict' is set to True, then those strings that are not entirely strictly conforming to JSON will result in a JSONDecodeError exception. * 'return_errors' (Boolean, default False) Controls the return value from this function. If False, then only the Python equivalent object is returned on success, or an error will be raised as an exception. If True then a 2-tuple is returned: (object, error_list). The error_list will be an empty list [] if the decoding was successful, otherwise it will be a list of all the errors encountered. Note that it is possible for an object to be returned even if errors were encountered. * 'return_stats' (Boolean, default False) Controls whether statistics about the decoded JSON document are returns (and instance of decode_statistics). If True, then the stats object will be added to the end of the tuple returned. If return_errors is also set then a 3-tuple is returned, otherwise a 2-tuple is returned. * 'write_errors' (Boolean OR File-like object, default False) Controls what to do with errors. - If False, then the first decoding error is raised as an exception. - If True, then errors will be printed out to sys.stderr. - If a File-like object, then errors will be printed to that file. The write_errors and return_errors arguments can be set independently. * 'filename_for_errors' (string or None) Provides a filename to be used when writting error messages. * 'allow_xxx', 'warn_xxx', and 'forbid_xxx' (Booleans) These arguments allow for fine-adjustments to be made to the 'strict' argument, by allowing or forbidding specific syntaxes. There are many of these arguments, named by replacing the "xxx" with any number of possible behavior names (See the JSON class for more details). Each of these will allow (or forbid) the specific behavior, after the evaluation of the 'strict' argument. For example, if strict=True then by also passing 'allow_comments=True' then comments will be allowed. If strict=False then forbid_comments=True will allow everything except comments. Unicode decoding: ----------------- The input string can be either a python string or a python unicode string (or a byte array in Python 3). If it is already a unicode string, then it is assumed that no character set decoding is required. However, if you pass in a non-Unicode text string (a Python 2 'str' type or a Python 3 'bytes' or 'bytearray') then an attempt will be made to auto-detect and decode the character encoding. This will be successful if the input was encoded in any of UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE), and of course plain ASCII works too. Note though that if you know the character encoding, then you should convert to a unicode string yourself, or pass it the name of the 'encoding' to avoid the guessing made by the auto detection, as with python_object = demjson.decode( input_bytes, encoding='utf8' ) Callback hooks: --------------- You may supply callback hooks by using the hook name as the named argument, such as: decode_float=decimal.Decimal See the hooks documentation on the JSON.set_hook() method. decode_file(filename, encoding=None, **kwargs) Decodes JSON found in the given file. See the decode() function for a description of other possible options. determine_float_limits(number_type=) Determines the precision and range of the given float type. The passed in 'number_type' argument should refer to the type of floating-point number. It should either be the built-in 'float', or decimal context or constructor; i.e., one of: # 1. FLOAT TYPE determine_float_limits( float ) # 2. DEFAULT DECIMAL CONTEXT determine_float_limits( decimal.Decimal ) # 3. CUSTOM DECIMAL CONTEXT ctx = decimal.Context( prec=75 ) determine_float_limits( ctx ) Returns a named tuple with components: ( significant_digits, max_exponent, min_exponent ) Where: * significant_digits -- maximum number of *decimal* digits that can be represented without any loss of precision. This is conservative, so if there are 16 1/2 digits, it will return 16, not 17. * max_exponent -- The maximum exponent (power of 10) that can be represented before an overflow (or rounding to infinity) occurs. * min_exponent -- The minimum exponent (negative power of 10) that can be represented before either an underflow (rounding to zero) or a subnormal result (loss of precision) occurs. Note this is conservative, as subnormal numbers are excluded. determine_float_precision() # For backwards compatibility with older demjson versions: encode(obj, encoding=None, **kwargs) Encodes a Python object into a JSON-encoded string. * 'strict' (Boolean, default False) If 'strict' is set to True, then only strictly-conforming JSON output will be produced. Note that this means that some types of values may not be convertable and will result in a JSONEncodeError exception. * 'compactly' (Boolean, default True) If 'compactly' is set to True, then the resulting string will have all extraneous white space removed; if False then the string will be "pretty printed" with whitespace and indentation added to make it more readable. * 'encode_namedtuple_as_object' (Boolean or callable, default True) If True, then objects of type namedtuple, or subclasses of 'tuple' that have an _asdict() method, will be encoded as an object rather than an array. If can also be a predicate function that takes a namedtuple object as an argument and returns True or False. * 'indent_amount' (Integer, default 2) The number of spaces to output for each indentation level. If 'compactly' is True then indentation is ignored. * 'indent_limit' (Integer or None, default None) If not None, then this is the maximum limit of indentation levels, after which further indentation spaces are not inserted. If None, then there is no limit. CONCERNING CHARACTER ENCODING: The 'encoding' argument should be one of: * None - The return will be a Unicode string. * encoding_name - A string which is the name of a known encoding, such as 'UTF-8' or 'ascii'. * codec - A CodecInfo object, such as as found by codecs.lookup(). This allows you to use a custom codec as well as those built into Python. If an encoding is given (either by name or by codec), then the returned value will be a byte array (Python 3), or a 'str' string (Python 2); which represents the raw set of bytes. Otherwise, if encoding is None, then the returned value will be a Unicode string. The 'escape_unicode' argument is used to determine which characters in string literals must be \u escaped. Should be one of: * True -- All non-ASCII characters are always \u escaped. * False -- Try to insert actual Unicode characters if possible. * function -- A user-supplied function that accepts a single unicode character and returns True or False; where True means to \u escape that character. Regardless of escape_unicode, certain characters will always be \u escaped. Additionaly any characters not in the output encoding repertoire for the encoding codec will be \u escaped as well. encode_to_file(filename, obj, encoding='utf-8', overwrite=False, **kwargs) Encodes a Python object into JSON and writes into the given file. If no encoding is given, then UTF-8 will be used. See the encode() function for a description of other possible options. If the file already exists and the 'overwrite' option is not set to True, then the existing file will not be overwritten. (Note, there is a subtle race condition in the check so there are possible conditions in which a file may be overwritten) extend_and_flatten_list_with_sep(orig_seq, extension_seq, separator='') extend_list_with_sep(orig_seq, extension_seq, sepchar='') skipstringsafe(s, start=0, end=None) skipstringsafe_slow(s, start=0, end=None) smart_sort_transform(key) DATA ALLOW = 'allow' FORBID = 'forbid' NUMBER_AUTO = 'auto' NUMBER_DECIMAL = 'decimal' NUMBER_FLOAT = 'float' NUMBER_FORMAT_BINARY = 'binary' NUMBER_FORMAT_DECIMAL = 'decimal' NUMBER_FORMAT_HEX = 'hex' NUMBER_FORMAT_LEGACYOCTAL = 'legacyoctal' NUMBER_FORMAT_OCTAL = 'octal' SORT_ALPHA = 'alpha' SORT_ALPHA_CI = 'alpha_ci' SORT_NONE = 'none' SORT_PRESERVE = 'preserve' SORT_SMART = 'smart' STRICTNESS_STRICT = 'strict' STRICTNESS_TOLERANT = 'tolerant' STRICTNESS_WARN = 'warn' WARN = 'warn' __author__ = 'Deron Meranda ' __credits__ = 'Copyright (c) 2006-2014 Deron E. Meranda CREDITS Copyright (c) 2006-2014 Deron E. Meranda Licensed under GNU LGPL (GNU Lesser General Public License) version 3.0 or later. See LICENSE.txt included with this software. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see or .