Implement metadata to_internal_json_structure in a way which allows deserialization

And then also implement from_internal_json_structure.

Currently, to_internal_json_structure is used just for debugging purposes and it losses information (by converting some values to their Python string representation) when converting to JSON in a way that it is not reversible.

For purpose of implementing #227 (closed) we would need a way to serialize metadata to JSON and then deserialize it back.

I suggest to_internal_json_structure is made to do so.