I think you can change this to show_captions.to_json(self.show_captions).