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

Function load_prefixed_json

httpie/output/utils.py:9–24  ·  view source on GitHub ↗

Simple JSON loading from `data`.

(data: str)

Source from the content-addressed store, hash-verified

7
8
9def load_prefixed_json(data: str) -> Tuple[str, json.JSONDecoder]:
10 """Simple JSON loading from `data`.
11
12 """
13 # First, the full data.
14 try:
15 return '', load_json_preserve_order_and_dupe_keys(data)
16 except ValueError:
17 pass
18
19 # Then, try to find the start of the actual body.
20 data_prefix, body = parse_prefixed_json(data)
21 try:
22 return data_prefix, load_json_preserve_order_and_dupe_keys(body)
23 except ValueError:
24 raise ValueError('Invalid JSON')
25
26
27def parse_prefixed_json(data: str) -> Tuple[str, str]:

Callers 1

format_bodyMethod · 0.85

Calls 2

parse_prefixed_jsonFunction · 0.85

Tested by

no test coverage detected