MCPcopy Create free account
hub / github.com/Layout-Parser/layout-parser / load_json

Function load_json

src/layoutparser/io/basic.py:29–44  ·  view source on GitHub ↗

Load a JSON file and save it as a layout object with appropriate data types. Args: filename (str): The name of the JSON file. Returns: Union[BaseLayoutElement, Layout]: Based on the JSON file format, it will automatically parse the type o

(filename: str)

Source from the content-addressed store, hash-verified

27
28
29def load_json(filename: str) -> Union[BaseLayoutElement, Layout]:
30 """Load a JSON file and save it as a layout object with appropriate data types.
31
32 Args:
33 filename (str):
34 The name of the JSON file.
35
36 Returns:
37 Union[BaseLayoutElement, Layout]:
38 Based on the JSON file format, it will automatically parse
39 the type of the data and load it accordingly.
40 """
41 with open(filename, "r") as fp:
42 res = json.load(fp)
43
44 return load_dict(res)
45
46
47def load_dict(data: Union[Dict, List[Dict]]) -> Union[BaseLayoutElement, Layout]:

Callers 2

test_jsonFunction · 0.90

Calls 1

load_dictFunction · 0.85

Tested by 2

test_jsonFunction · 0.72