Serialize the item. Required for storing in the containing cache
425217
public function serialize()
    {
        return serialize([
            'key' => $this->key,
            'value' => $this->value,
            'expires' => $this->expires,
            'hit' => $this->hit
        ]);
    }
1003085
def serialize(self) -> dict:
        
        data = {**self}
        if "attachments" in self:
            data["attachments"] = json.dumps(self["attachments"])
        return data
643954
def serialize(self, data):
        
        if data is None:
            return None
        elif isinstance(data, dict):
            return serializer.Serializer().serialize(data)
        else:
            raise Exception(_("Unable to serialize object of type = '%s'") %
                            type(data))
800829
def _serialize_property_value(self, to_serialize: Any, serializer_cls: Type) -> Any:
        
        serializer = self._create_serializer_of_type_with_cache(serializer_cls)
        assert serializer is not None
        return serializer.serialize(to_serialize)
1163973
def _serialize(self):
        
        result = { a: getattr(self, a) for a in type(self).properties
            if type(self).properties[a].mutable }

        for k, v in result.items():
            if isinstance(v, Base):
                result[k] = v.id

        return result
1132836
def get(self, CachableItem):
        """"""
        cached_item = self.mapper.get(CachableItem)
        r = self.request('get',
            self.url+"storage/collections/data/"+self.collname+'/'+cached_item.getId(),
            data={'output_mode': 'json'})
        if r.ok:
            # we need to update the object with the values found in the cache area
            data = r.json()
            for name in self.mapper.mapper:
                setattr(cached_item, name, data[name])
            return cached_item
        return None
1356021
def _serialize_data(self, data):
        

        data.update(data['include'])
        data.update(data['to_many'])
        data.update(data['to_one'])

        for key, val in data.items():
            if isinstance(val, dict):
                pass
            elif isinstance(val, list):
                pass
            else:
                str(val)
712556
public function serialize(): void
    {
        $keysgroup = [];

        if (! isset($this->transaction['version']) || 1 === $this->transaction['version']) {
            foreach ($this->transaction['asset']['multisignature']['keysgroup'] as $key) {
                $keysgroup[] = '+' === substr($key, 0, 1)
                    ? substr($key, 1)
                    : $key;
            }
        } else {
            $keysgroup = $this->transaction['asset']['multisignature']['keysgroup'];
        }

        $this->buffer->writeUInt8($this->transaction['asset']['multisignature']['min']);
        $this->buffer->writeUInt8(count($this->transaction['asset']['multisignature']['keysgroup']));
        $this->buffer->writeUInt8($this->transaction['asset']['multisignature']['lifetime']);
        $this->buffer->writeHexBytes(implode('', $keysgroup));
    }
16321
def _serialize_item(item):
    """"""
    # Recursively serialize lists, tuples, and dicts.
    if isinstance(item, (list, tuple)):
        return [_serialize_item(subitem) for subitem in item]
    elif isinstance(item, dict):
        return dict([(key, _serialize_item(value))
                     for (key, value) in iteritems(item)])

    # Serialize strings.
    elif isinstance(item, string_types):
        # Replace glSomething by something (needed for WebGL commands).
        if item.startswith('gl'):
            return re.sub(r'^gl([A-Z])', lambda m: m.group(1).lower(), item)
        else:
            return item

    # Process NumPy arrays that are not buffers (typically, uniform values).
    elif isinstance(item, np.ndarray):
        return _serialize_item(item.ravel().tolist())

    # Serialize numbers.
    else:
        try:
            return np.asscalar(item)
        except Exception:
            return item
921964
def serialize(self, serializable: Optional[Union[SerializableType, List[SerializableType]]]) \
            -> PrimitiveJsonType:
        
        if serializable is None:
            # Implements #17
            return None
        elif isinstance(serializable, List):
            return [self.serialize(item) for item in serializable]
        else:
            serialized = self._create_serialized_container()

            for mapping in self._property_mappings:
                if mapping.object_property_getter is not None and mapping.serialized_property_setter is not None:
                    value = mapping.object_property_getter(serializable)
                    if not (mapping.optional and value is None):
                        if isinstance(value, type(mapping.collection_factory([]))):
                            value = list(mapping.collection_iter(value))
                        encoded_value = self._serialize_property_value(value, mapping.serializer_cls)
                        mapping.serialized_property_setter(serialized, encoded_value)

            return serialized
1157798
def as_dict(self, cache=None, fetch=True):
        
        if not self._fetched and fetch:
            info = self.fetch(cache)
        elif self._use_cache(cache):
            info = self._attrs.copy()
        else:
            info = {}
        info.update(url=self.url)
        return info
267116
def Serialize(self, writer):
        
        writer.WriteUInt256(self.AssetId)
        writer.WriteFixed8(self.Value)
        writer.WriteUInt160(self.ScriptHash)
792339
protected function serializeToStorage()
  {
    $this->debugLog('serializeToStorage()');
    $this->storage->updateLists($this->lists);
    $this->storage->setUpdaterState($this->next_request_timestamp, $this->error_count);
    
    $this->debugLog('current memory usage: '.memory_get_usage());
    $this->debugLog('peak memory usage   : '.memory_get_peak_usage());
  }
1273576
def _serialize(self, version, serialize_format, context, raise_if_incomplete=False):
        
        values = context.copy()
        for k in version:
            values[k] = version[k]

        # TODO dump complete context on debug level

        try:
            # test whether all parts required in the format have values
            serialized = serialize_format.format(**values)

        except KeyError as e:
            missing_key = getattr(e, "message", e.args[0])
            raise MissingValueForSerializationException(
                "Did not find key {} in {} when serializing version number".format(
                    repr(missing_key), repr(version)
                )
            )

        keys_needing_representation = set()
        found_required = False

        for k in self.order():
            v = values[k]

            if not isinstance(v, VersionPart):
                # values coming from environment variables don't need
                # representation
                continue

            if not v.is_optional():
                found_required = True
                keys_needing_representation.add(k)
            elif not found_required:
                keys_needing_representation.add(k)

        required_by_format = set(self._labels_for_format(serialize_format))

        # try whether all parsed keys are represented
        if raise_if_incomplete:
            if not (keys_needing_representation <= required_by_format):
                raise IncompleteVersionRepresentationException(
                    "Could not represent '{}' in format '{}'".format(
                        "', '".join(keys_needing_representation ^ required_by_format),
                        serialize_format,
                    )
                )

        return serialized
167951
def needs_serialization(self):
        
        return any(field.is_set_on(self) for field in six.itervalues(self.fields))
132025
def _serialize(cls, key, value, fields):
        
        converter = cls._get_converter_for_field(key, None, fields)
        return converter.serialize(value)
475383
def serializable(wrapped):
    

    @wraps(wrapped)
    def wrapper(*args, **kwargs):
        should_serialize = kwargs.pop('serialize', False)
        result = wrapped(*args, **kwargs)

        return serialize(result) if should_serialize else result

    if hasattr(wrapped, 'decorators'):
        wrapper.decorators = wrapped.decorators
        wrapper.decorators.append('serializable')
    else:
        wrapper.decorators = ['serializable']

    return wrapper