util.persistence.serializePlist module

Inheritance diagram of PlistSerializationStrategy

Serialization to Apple’s property list (plist) format, in its XML form.

A plist can hold dicts (with string keys), arrays, strings, integers, reals and booleans – exactly the structure JSONSerializationStrategy builds – so this strategy reuses that encoding wholesale and only replaces the final step: the structure is written and read with plistlib instead of json. Everything the JSON strategy supports, including Serializable classes, works here too.

Plists can’t hold None (the JSON strategy never produces one: None is encoded as a tagged string), integers beyond 64 bits, or strings containing characters XML forbids (eg: most control characters); plistlib raises an exception for those.

Created on Sep 28, 2026

Code author: Rob Kremer <robkremer@me.com>

class util.persistence.serializePlist.PlistSerializationStrategy

Bases: JSONSerializationStrategy

Reads and writes Apple XML property lists, using the JSON strategy’s encoding of objects (see the module documentation).

classmethod defaultExtension() → str
Returns:

Return type:

str

classmethod sniff(start: bytes) → int
Returns:

2 for a property list (XML or binary).

classmethod protocolName() → str
Returns:

Return type:

str

classmethod protocolVersion() → str
Returns:

Return type:

str

_tostring(elem: dict | list | int | float | bool | str, kwargs: dict[str, Any]) → str
Parameters:
  • kwargs – “sort_keys” (default False, so dicts keep their order, as in the other formats) is passed on to plistlib.dumps().

  • elem (JSONtypes)

Returns:

Return type:

str

_fromstring(string: str, kwargs: dict[str, Any]) → dict | list | int | float | bool | str
Parameters:
  • string (str)

  • kwargs (dict[str, Any])

Returns:

Return type:

JSONtypes

_abc_impl = <_abc._abc_data object>