Exemple #1
0
def loads(s, **kwargs):
    """Unserialize a JSON object from a string ``s`` by using the application's
    configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
    application on the stack.
    """
    _load_arg_defaults(kwargs)
    return _json.loads(s, **kwargs)
Exemple #2
0
def loads(s, **kwargs):
    """Unserialize a JSON object from a string ``s`` by using the application's
    configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
    application on the stack.
    """
    _load_arg_defaults(kwargs)
    return _json.loads(s, **kwargs)
Exemple #3
0
def loads(s, **kwargs):
    """Unserialize a JSON object from a string ``s`` by using the application's
    configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
    application on the stack.
    """
    if current_app:
        kwargs.setdefault('cls', current_app.json_decoder)
    return _json.loads(s, **kwargs)
Exemple #4
0
def loads(s, **kwargs):
    """Unserialize a JSON object from a string ``s`` by using the application's
    configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
    application on the stack.
    """
    if current_app:
        kwargs.setdefault('cls', current_app.json_decoder)
    return _json.loads(s, **kwargs)
Exemple #5
0
def loads(s, **kwargs):
    """Unserialize a JSON object from a string ``s`` by using the application's
    configured decoder (:attr:`~flask.Flask.json_decoder`) if there is an
    application on the stack.
    """
    _load_arg_defaults(kwargs)
    if isinstance(s, bytes):
        s = s.decode(kwargs.pop('encoding', None) or 'utf-8')
    return _json.loads(s, **kwargs)
Exemple #6
0
    def _obj_from_json(self, filename):
        try:
            with open(filename) as json_file:
                obj = _json.loads(json_file.read())

        except Exception as e:
            log.critical('Unable to load configuration file (%s)' % e.message)
            exit(1)
        return obj
Exemple #7
0
    def _obj_from_json(self, filename):
        try:
            with open(filename) as json_file:
                obj = _json.loads(json_file.read())

        except Exception as e:
            log.critical('Unable to load configuration file (%s)' % e.message)
            exit(1)
        return obj
Exemple #8
0
def loads(s, **kwargs):
    _load_arg_defaults(kwargs)
    if isinstance(s, bytes):
        s = s.decode(kwargs.pop('encoding', None) or 'utf-8')
    return _json.loads(s, **kwargs)