MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / json

Method json

mitmproxy/http.py:496–513  ·  view source on GitHub ↗

Returns the JSON encoded content of the response, if any. `**kwargs` are optional arguments that will be passed to `json.loads()`. Will raise if the content can not be decoded and then parsed as JSON. *Raises:* - `json.decoder.JSONDecodeError` if c

(self, **kwargs: Any)

Source from the content-addressed store, hash-verified

494 raise ValueError(f"Invalid content encoding {encoding!r}")
495
496 def json(self, **kwargs: Any) -> Any:
497 """
498 Returns the JSON encoded content of the response, if any.
499 `**kwargs` are optional arguments that will be
500 passed to `json.loads()`.
501
502 Will raise if the content can not be decoded and then parsed as JSON.
503
504 *Raises:*
505 - `json.decoder.JSONDecodeError` if content is not valid JSON.
506 - `TypeError` if the content is not available, for example because the response
507 has been streamed.
508 """
509 content = self.get_content(strict=False)
510 if content is None:
511 raise TypeError("Message content is not available.")
512 else:
513 return json.loads(content, **kwargs)
514
515
516class Request(Message):

Callers 10

test_get_jsonMethod · 0.45
echo_responseMethod · 0.45
runCommandFunction · 0.45
CommandBarFunction · 0.45
onKeyDownFunction · 0.45
handleClickCopyButtonFunction · 0.45
componentDidMountMethod · 0.45
fetchDataMethod · 0.45
fetchDataMethod · 0.45
processes.tsFile · 0.45

Calls 2

get_contentMethod · 0.95
loadsMethod · 0.80

Tested by 2

test_get_jsonMethod · 0.36
echo_responseMethod · 0.36