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)
| 27 | |
| 28 | |
| 29 | def 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 | |
| 47 | def load_dict(data: Union[Dict, List[Dict]]) -> Union[BaseLayoutElement, Layout]: |