Base
JSONEncoder
Bases: JSONEncoder
Custom JSON encoder to handle numpy types and other special objects
Source code in Docs2KG/kg_construction/base.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
KGConstructionBase
Source code in Docs2KG/kg_construction/base.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
export_json(data, filename, ensure_ascii=False)
Export data to a JSON file with improved type handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
Any
|
The data to export |
required |
filename
|
Union[str, Path]
|
Name of the output file |
required |
ensure_ascii
|
bool
|
If False, allow non-ASCII characters in output |
False
|
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path to the exported file |
Raises:
Type | Description |
---|---|
IOError
|
If there's an error writing the file |
TypeError
|
If an object type cannot be serialized |
Source code in Docs2KG/kg_construction/base.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|