caption fix

added json_encode(), which guarantees the output will be syntactically
valid Javascript, so I can have apostrophe's in captions