Refactor top-level JSON encoding/decoding

The TripHistory class wasn’t necessary in the end, so just expose
top-level functions to do the same thing.
Implement import/export