Make toJSON throw an error on a bad key (invalid characters)