Encode & in JSON encoded attributes.

This fixes the SyntaxErrors in #1732.