from datetime import datetime
import json


def save_json(obj: dict, path: str):
    """Save object to .json file.

    json.dump(default) is used to serialize datetime as
    object like {type: datetime, value: 2021-04-01}.
    """

    def default(unserializable):
        if isinstance(unserializable, datetime):
            return {"type": "datetime", "value": str(unserializable)}
        raise TypeError("not supported")

    with open(path, "w", encoding="utf_8") as f:
        json.dump(obj, f, indent=4, default=default)