bokeh/bokeh · container.py
python logo
def from_json(self, json, models=None):
        if json is None:
            return None
        elif isinstance(json, dict):
            return { self.keys_type.from_json(key, models): self.values_type.from_json(value, models) for key, value in iteritems(json) }
        else:
            raise DeserializationError("%s expected a dict or None, got %s" % (self, json))
Similar code snippets
1.
bokeh/bokeh · container.py
Match rating: 80.47% · See similar code snippets
python logo
def from_json(self, json, models=None):
        if json is None:
            return None
        elif isinstance(json, list):
            return self._new_instance([ self.item_type.from_json(item, models) for item in json ])
        else:
            raise DeserializationError("%s expected a list or None, got %s" % (self, json))
2.
bokeh/bokeh · container.py
Match rating: 77.72% · See similar code snippets
python logo
def from_json(self, json, models=None):
        if json is None:
            return None
        elif isinstance(json, list):
            return tuple(type_param.from_json(item, models) for type_param, item in zip(self.type_params, json))
        else:
            raise DeserializationError("%s expected a list or None, got %s" % (self, json))
3.
i3visio/osrframework · utils.py
Match rating: 66.15% · 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)
4.
GoogleCloudPlatform/appengine-mapreduce · key_ranges.py
Match rating: 65.41% · See similar code snippets
python logo
def from_json(cls, json):
    """Deserialize from json.

    Args:
      json: a dict of json compatible fields.

    Returns:
      a KeyRanges object.

    Raises:
      ValueError: if the json is invalid.
    """
    if json["name"] in _KEYRANGES_CLASSES:
      return _KEYRANGES_CLASSES[json["name"]].from_json(json)
    raise ValueError("Invalid json %s", json)
5.
GoogleCloudPlatform/appengine-mapreduce · json_util.py
Match rating: 64.56% · 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))
6.
GoogleCloudPlatform/appengine-mapreduce · key_ranges.py
Match rating: 64.54% · See similar code snippets
python logo
def from_json(cls, json):
    return cls(
        [key_range.KeyRange.from_json(kr) for kr in json["list_of_key_ranges"]])
7.
bokeh/bokeh · either.py
Match rating: 64.32% · See similar code snippets
python logo
def from_json(self, json, models=None):
        for tp in self.type_params:
            try:
                return tp.from_json(json, models)
            except DeserializationError:
                pass
        else:
            raise DeserializationError("%s couldn't deserialize %s" % (self, json))
8.
CybOXProject/mixbox · entities.py
Match rating: 63.92% · See similar code snippets
python logo
def from_json(cls, json_doc):
        """Parse a JSON string and build an entity."""
        try:
            d = json.load(json_doc)
        except AttributeError:  # catch the read() error
            d = json.loads(json_doc)

        return cls.from_dict(d)
9.
GoogleCloudPlatform/appengine-mapreduce · input_readers.py
Match rating: 63.65% · See similar code snippets
python logo
def from_json(cls, json):
    return cls(json[cls.COUNT], json[cls.STRING_LENGTH])
10.
cfhamlet/os-config · config.py
Match rating: 63.47% · See similar code snippets
python logo
def from_json(cls, j):
        d = json.loads(j)
        return cls.from_dict(d)