Add a `to_json` method to top-level namespace
To explicitly encourage / support serialisation of other objects (e.g. numpy arrays) and better support custom JSON serialisation of Pandas types. As discussed in #9130.

Would welcome more thoughts / ideas on this. Not 100% sold myself.
