# VDF serializer

`VDF` is format similar to JSON or YAML, used by Valve to store data. This module mimics built-in `json` module and provides functions for serialization and deserialization of `VDF` files.

steam.vdf.dump(obj, stream)

  Serializes obj as VDF formatted stream to stream object, encoded as UTF-16 by default.

    >>> with open('dump.vdf', 'w') as file:
    ...     vdf.dump({u"key": u"value", u"list": [1, 2, 3]}, file)

    → cat dump.vdf
    "list"
    {
    "1" "1"
    "2" "1"
    "3" "1"
    }

    "key" "value"

steam.vdf.dumps(obj)

  Serializes obj as VDF formatted string, encoded as UTF-16 by default.

    >>> vdf_obj = vdf.dumps({"key": "value", "list": [1, 2, 3]})
    >>> vdf_obj.decode('utf-16')
    u'\n  "list"\n  {\n    "1" "1"\n    "2" "1"\n    "3" "1"\n  }\n\n  "key" "value"\n'

steam.vdf.load(stream)

  Deserializes stream containing VDF document to Python object.

    >>> with open('dump.vdf', 'r') as file:
    ...     vdf.load(file)
    ...
    {u'list': {u'1': u'1', u'3': u'1', u'2': u'1'}, u'key': u'value'}

steam.vdf.loads(string)

  Deserializes string containing VDF document to Python object.

    >>> vdf.loads('"list" { "a" "1" "b" "2" "c" "3" }')
    {u'list': {u'a': u'1', u'c': u'3', u'b': u'2'}}