VForWaTer / metacatalog

Modular metadata management platform for environmental data.
https://vforwater.github.io/metacatalog
GNU General Public License v3.0
3 stars 1 forks source link

Non JSON serializable entry result #104

Closed MarcusStrobl closed 3 years ago

MarcusStrobl commented 3 years ago

The result of find_entry of the API has datetime and boolean in it, which are not JSON serializable. Is it feasible to return only string in the metadata (or maybe a flag or a new function), or is the user supposed to serialize the result himself?

mmaelicke commented 3 years ago

Hey, I would not return only string, as the models can be used directly in Python and then having only string values whould be a huge downside.

There is a utility function doing almost everything you need in a nested way: https://github.com/VForWaTer/metacatalog/blob/6d69cd4b336fa5558182505baa570ae3f832e391/metacatalog/util/dict_functions.py#L43

We would need to extend the __convert function underneath for bool. For convenience, I would suggest to introduce a stringify parameter to all models to_dict functions, which calls the serialize function.