Wrapper function for decoding the provided JSON string. This function automatically select appropriate JSON library based on the configuration value. This function should be used everywhere in the code base where json.loads() behavior is desired.
(data)
| 119 | |
| 120 | |
| 121 | def json_decode(data): |
| 122 | """ |
| 123 | Wrapper function for decoding the provided JSON string. |
| 124 | |
| 125 | This function automatically select appropriate JSON library based on the configuration value. |
| 126 | |
| 127 | This function should be used everywhere in the code base where json.loads() behavior is desired. |
| 128 | """ |
| 129 | json_library = DEFAULT_JSON_LIBRARY |
| 130 | |
| 131 | if json_library == "json": |
| 132 | return json_decode_native_json(data=data) |
| 133 | elif json_library == "orjson": |
| 134 | return json_decode_orjson(data=data) |
| 135 | else: |
| 136 | raise ValueError("Unsupported json_library: %s" % (json_library)) |
| 137 | |
| 138 | |
| 139 | def load_file(path): |
no test coverage detected