Add toJSON in twig extension