Draft implementation of JSON serialiser.