JSON export/import

Implementation is fairly stupid (encoders/decoders could easily be
autogenerated from a list of fields per data type) and does not have
enough tests, but should be good enough to play around with.
Would be good to have a phpunit test for the round trip