added comment to json converter

This commit is contained in:
Certainly Not a Genius 2024-12-25 21:58:02 +01:00
parent 23e1fbb064
commit 25b4089917

View file

@ -1206,14 +1206,21 @@ class ZipConverter(DocumentConverter):
class JsonConverter(DocumentConverter): class JsonConverter(DocumentConverter):
"""Converts generic json files to markdown :
- keys are prefixed with the whole dictionnary tree starting with the file name
- values are kept untouched
- key/values are between backtips
- (ordered) lists are converted into markdown ordered lists starting at 0."""
def convert( def convert(
self, local_path: str, **kwargs: Any self, local_path: str, **kwargs: Any
) -> Union[None, DocumentConverterResult]: ) -> Union[None, DocumentConverterResult]:
# Bail if not an image
extension = kwargs.get("file_extension", "") extension = kwargs.get("file_extension", "")
if extension.lower() not in [".json"]: if extension.lower() not in [".json"]:
return None return None
# TODO : check similar extensions and/or mime type
with open(local_path) as test_json: with open(local_path) as test_json:
try: try:
json_data = json.load(test_json) json_data = json.load(test_json)