Convert ImmutableDict to dict before passing it to json.dumps.
To work with the new swh-model version, which uses ImmutableDict in model objects.
Introducing the map_optional
function just for that may seem pointless, but I use it a lot in !446 (closed).
Migrated from D3476 (view on Phabricator)