              'bar': [{'code': 'required', 'message': 'This field is required.'}],
              '__all__': [{'code': 'secret', 'message': 'Non-field error.'}]
          }
          self.assertEqual(errors, control)
  
      def test_error_dict_as_json_escape_html(self):
          """#21962 - adding html escape flag to ErrorDict"""
          class MyForm(Form):
              foo = CharField()
              bar = CharField()
 
</s> remove         errors = json.loads(form.errors.as_json())
 </s> add         errors = form.errors.get_json_data() </s> remove         return json.dumps({f: e.get_json_data(escape_html) for f, e in self.items()})
 </s> add         return json.dumps(self.get_json_data(escape_html))
        self.assertEqual(json.dumps(errors), form.errors.as_json())
              'bar': [{'code': 'required', 'message': 'This field is required.'}],
              '__all__': [{'code': 'secret', 'message': 'Non-field error.'}]
          }
          self.assertEqual(errors, control)
        self.assertEqual(json.dumps(errors), form.errors.as_json())
  
      def test_error_dict_as_json_escape_html(self):
          """#21962 - adding html escape flag to ErrorDict"""
          class MyForm(Form):
              foo = CharField()
              bar = CharField()
keep keep keep add keep keep keep keep keep keep
 Fixed #27922 -- Added ErrorDict.get_json_data(). 
tests/forms_tests/tests/test_forms.py