MCPcopy
hub / github.com/django/django / _encode_json

Method _encode_json

django/test/client.py:450–458  ·  view source on GitHub ↗

Return encoded JSON if data is a dict, list, or tuple and content_type is application/json.

(self, data, content_type)

Source from the content-addressed store, hash-verified

448 return force_bytes(data, encoding=charset)
449
450 def _encode_json(self, data, content_type):
451 """
452 Return encoded JSON if data is a dict, list, or tuple and content_type
453 is application/json.
454 """
455 should_encode = JSON_CONTENT_TYPE_RE.match(content_type) and isinstance(
456 data, (dict, list, tuple)
457 )
458 return json.dumps(data, cls=self.json_encoder) if should_encode else data
459
460 def _get_path(self, parsed):
461 path = unquote_to_bytes(parsed.path)

Callers 4

postMethod · 0.95
putMethod · 0.95
patchMethod · 0.95
deleteMethod · 0.95

Calls 2

matchMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected