serialize

negmas.serialization.serialize(value, deep=True, add_type_field=True, keep_private=False, ignore_methods=True, ignore_lambda=False, shorten_type_field=False, objmem=None)[source]

Encodes the given value as nothing more complex than simple dict of either dicts, lists or builtin numeric or string values. The resulting dictionary will be json serializable

Parameters:
  • value (giving the type of) – Any object

  • deep – Whether we should go deep in the encoding or do a shallow encoding

  • add_type_field – Whether to add a type field. If True, A field named PYTHON_CLASS_IDENTIFIER will be added

  • value

  • keep_private – Keeps fields starting with “_”

  • shorten_type_field – IF given, the type will be shortened to class name only if it starts with “negmas.”

Remarks:

  • All iterables are converted to lists when deep is true.

  • If the value object has a to_dict member, it will be called to do the conversion, otherwise its __dict__ or __slots__ member will be used.

See also

deserialize, PYTHON_CLASS_IDENTIFIER