Fix encoding of JSON attributes