def set_from_json(self, obj, json, models=None):
        if isinstance(json, dict):
            # we want to try to keep the "format" of the data spec as string, dict, or number,
            # assuming the serialized dict is compatible with that.
            old = getattr(obj, self.name)
            if old is not None:
                try:
                    self.descriptor._type.validate(old)
                    if 'value' in json:
                        json = json['value']
                except ValueError:
                    if isinstance(old, string_types) and 'field' in json:
                        json = json['field']
                # leave it as a dict if 'old' was a dict

        super(DataSpecProperty, self).set_from_json(obj, json, models)
dataset/ETHPy150Open bokeh/bokeh/bokeh/core/properties.py/DataSpecProperty.set_from_json/original