Method to convert all metadata to JSON
See https://github.com/tskit-dev/tsinfer/discussions/629 for a use-case and https://github.com/tskit-dev/tsinfer/discussions/629#discussioncomment-2155840 for some code that I think does the trick, modulo top-level metadata.
There might be difficulty if there is stuff in a schema that can't be serialised into JSON. So perhaps this is a tricky thing that is only worth considering if other software developers hit the problem. I.e. if they want to create software (e.g. tsinfer.SampleData.from_tree_sequence) that takes an existing tree sequence produced by some other software that defines its own schema (e.g. SLiM) and return a modified tree sequence with some extra metadata added to it.
Thanks @hyanwong, I've added this to the metadata project for when we design out the API.