If the ``Content-Type`` header is ``application/json``, this property holds the parsed content of the request body. Only requests smaller than :attr:`MEMFILE_MAX` are processed to avoid memory exhaustion.
(self)
| 1117 | |
| 1118 | @DictProperty('environ', 'bottle.request.json', read_only=True) |
| 1119 | def json(self): |
| 1120 | ''' If the ``Content-Type`` header is ``application/json``, this |
| 1121 | property holds the parsed content of the request body. Only requests |
| 1122 | smaller than :attr:`MEMFILE_MAX` are processed to avoid memory |
| 1123 | exhaustion. ''' |
| 1124 | ctype = self.environ.get('CONTENT_TYPE', '').lower().split(';')[0] |
| 1125 | if ctype == 'application/json': |
| 1126 | b = self._get_body_string() |
| 1127 | if not b: |
| 1128 | return None |
| 1129 | return json_loads(b) |
| 1130 | return None |
| 1131 | |
| 1132 | def _iter_body(self, read, bufsize): |
| 1133 | maxread = max(0, self.content_length) |
no test coverage detected