--- prelude: > The `Document` serialisation has been changed quite a bit, this will make it easier to implement new Document Stores. The most notable change is that the `Document.flatten()` method has been removed. `Document.to_dict()` now has a `flatten` parameter, that defaults to `True` for backward compatibility. It will flatten metadata keys at the same level of other `Document` fields when converting to `dict`. `to_json` and `from_json` have been removed, as `to_dict` and `from_dict` already handle serialisation of `dataframe` and `blob` fields. Now `metadata` must only contain primitives that can be serialised to JSON with no custom encoders. If any Document Store needs custom serialisation they can implement their own logic. `Document` has also been made backward compatible so that it can be created using dictionaries structured as the legacy 1.x `Document`. The legacy fields will be converted automatically to their new counterparts, or ignored if there's none. preview: - | Refactor Document serialisation and make it backward compatible with Haystack 1.x