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.
$json is sometimes a string, sometimes an array. Maybe use $jsonData for the array.