AirtestProject/Poco · utils.py
python logo
def from_json(cls, json_str):
        data = cls.deserialize(json_str)

        if not isinstance(data, dict):
            raise ValueError("data should be dict")

        return cls(**data)
Similar code snippets
1.
pavlov99/json-rpc · jsonrpc2.py
Match rating: 80.62% · See similar code snippets
python logo
def from_json(cls, json_str):
        data = cls.deserialize(json_str)
        return cls.from_data(data)
2.
AirtestProject/Poco · exceptions.py
Match rating: 73.64% · See similar code snippets
python logo
def from_json(cls, json_str):
        data = cls.deserialize(json_str)
        return cls(
            code=data["code"], message=data["message"], data=data.get("data"))
3.
ProjetPP/PPP-datamodel-Python · serializableattributesholder.py
Match rating: 72.13% · See similar code snippets
python logo
def from_json(cls, data):
        """Decode a JSON string and inflate a node instance."""
        # Decode JSON string
        assert isinstance(data, str)
        data = json.loads(data)
        assert isinstance(data, dict)
        return cls.from_dict(data)
4.
juju/python-libjuju · facade.py
Match rating: 67.75% · See similar code snippets
python logo
def from_json(cls, data):
        if isinstance(data, cls):
            return data
        if isinstance(data, str):
            try:
                data = json.loads(data)
            except json.JSONDecodeError:
                raise
        d = {}
        for k, v in (data or {}).items():
            d[cls._toPy.get(k, k)] = v

        try:
            return cls(**d)
        except TypeError:
            raise
5.
i3visio/osrframework · utils.py
Match rating: 67.5% · See similar code snippets
python logo
def from_json(cls, json_str):
        """Deserialize the object from a JSON string."""
        d = json.loads(json_str)
        return cls.from_dict(d)
6.
GoogleCloudPlatform/appengine-mapreduce · json_util.py
Match rating: 66.53% · See similar code snippets
python logo
def from_json_str(cls, json_str):
    """Convert json string representation into class instance.

    Args:
      json_str: json representation as string.

    Returns:
      New instance of the class with data loaded from json string.
    """
    return cls.from_json(json.loads(json_str, cls=JsonDecoder))
7.
Mezgrman/TweetPony · models.py
Match rating: 63.27% · See similar code snippets
python logo
def from_json(cls, data):
		if type(data) is list and len(data) == 1:
			data = data[0]
		self = cls(Model.from_json(data))
		for key, value in self.iteritems():
			if key == self.model_key:
				value = self.collection.from_json(value)
			self[key] = value
		return self
8.
snare/voltron · api.py
Match rating: 63.0% · See similar code snippets
python logo
def from_json(self, data):
        """
        Initialise an API message from a JSON representation.
        """
        try:
            d = json.loads(data)
        except ValueError:
            raise InvalidMessageException()
        self.from_dict(d)
9.
Mezgrman/TweetPony · models.py
Match rating: 62.71% · See similar code snippets
python logo
def from_json(cls, data):
		self = cls(data)
		self['json'] = json.dumps(data)
		return self
10.
cfhamlet/os-config · config.py
Match rating: 61.87% · See similar code snippets
python logo
def from_json(cls, j):
        d = json.loads(j)
        return cls.from_dict(d)