MCPcopy
hub / github.com/httpie/cli / parse_prefixed_json

Function parse_prefixed_json

httpie/output/utils.py:27–37  ·  view source on GitHub ↗

Find the potential JSON body from `data`. Sometimes the JSON body is prefixed with a XSSI magic string, specific to the server. Return a tuple (data prefix, actual JSON body).

(data: str)

Source from the content-addressed store, hash-verified

25
26
27def parse_prefixed_json(data: str) -> Tuple[str, str]:
28 """Find the potential JSON body from `data`.
29
30 Sometimes the JSON body is prefixed with a XSSI magic string, specific to the server.
31 Return a tuple (data prefix, actual JSON body).
32
33 """
34 matches = re.findall(PREFIX_REGEX, data)
35 data_prefix = matches[0] if matches else ''
36 body = data[len(data_prefix):]
37 return data_prefix, body

Callers 1

load_prefixed_jsonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected