Fixing a compatibility problem with JsonSerializable interface for PHP versions prior to 5.4