Skip to content

Commit

Permalink
Fix json file parse (#4004)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

Fix json file parsing

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Signed-off-by: jinhai <[email protected]>
  • Loading branch information
JinHai-CN authored Dec 12, 2024
1 parent 9ae81b4 commit 275b5d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions deepdoc/parser/json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
from typing import Any

from rag.nlp import find_codec
class RAGFlowJsonParser:
def __init__(
Expand Down Expand Up @@ -53,7 +54,7 @@ def _list_to_dict_preprocessing(self, data: Any) -> Any:

def _json_split(
self,
data: dict[str, Any],
data,
current_path: list[str] | None,
chunks: list[dict] | None,
) -> list[dict]:
Expand Down Expand Up @@ -86,13 +87,14 @@ def _json_split(

def split_json(
self,
json_data: dict[str, Any],
json_data,
convert_lists: bool = False,
) -> list[dict]:
"""Splits JSON into a list of JSON chunks"""

if convert_lists:
chunks = self._json_split(self._list_to_dict_preprocessing(json_data), None, None)
preprocessed_data = self._list_to_dict_preprocessing(json_data)
chunks = self._json_split(preprocessed_data, None, None)
else:
chunks = self._json_split(json_data, None, None)

Expand Down

0 comments on commit 275b5d1

Please sign in to comment.