| 96 | |
| 97 | |
| 98 | class JSONBoundField(BoundField): |
| 99 | def as_form_field(self): |
| 100 | value = self.value |
| 101 | # When HTML form input is used and the input is not valid |
| 102 | # value will be a JSONString, rather than a JSON primitive. |
| 103 | if not getattr(value, 'is_json_string', False): |
| 104 | with contextlib.suppress(TypeError, ValueError): |
| 105 | value = json.dumps( |
| 106 | self.value, |
| 107 | sort_keys=True, |
| 108 | indent=4, |
| 109 | separators=(',', ': '), |
| 110 | ) |
| 111 | return self.__class__(self._field, value, self.errors, self._prefix) |
| 112 | |
| 113 | |
| 114 | class NestedBoundField(BoundField): |
no outgoing calls
no test coverage detected