def load_json(cls, data, default_rule=None): """Allow loading of JSON rule data.""" # Suck in the JSON data and parse the rules rules = dict((k, parse_rule(v)) for k, v in jsonutils.loads(data).items()) return cls(rules, default_rule)
def _from_json(self, datastring): value = datastring try: LOG.debug(_("Trying deserialize '{0}' to json".format(datastring))) value = jsonutils.loads(datastring) except ValueError: LOG.debug(_("Unable deserialize to json, using raw text")) return value
def load_json(cls, data, default_rule=None): """Allow loading of JSON rule data.""" # Suck in the JSON data and parse the rules rules = dict( (k, parse_rule(v)) for k, v in jsonutils.loads(data).items()) return cls(rules, default_rule)
def _from_json_patch(self, datastring): try: operations = jsonutils.loads(datastring) except ValueError: msg = _("cannot understand JSON") raise exception.MalformedRequestBody(reason=msg) changes = [] for raw_change in operations: if not isinstance(raw_change, dict): msg = _('Operations must be JSON objects.') raise webob.exc.HTTPBadRequest(explanation=msg) (op, path) = self._parse_json_schema_change(raw_change) self._validate_path(path) change = {'op': op, 'path': path} change['value'] = self._get_change_value(raw_change, op) self._validate_change(change) changes.append(change) return changes
def _from_json(self, datastring): try: return jsonutils.loads(datastring) except ValueError: msg = _("cannot understand JSON") raise exception.MalformedRequestBody(reason=msg)