Remove all non-printable characters right before generating json