Skip to content

Commit

Permalink
community: json loader not getting texts with json standard
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyBotongChu committed Oct 14, 2024
1 parent 2197958 commit 440c3bc
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,11 @@ def _get_text(self, sample: Any) -> str:
)

# In case the text is None, set it to an empty string
elif isinstance(content, str):
return content
elif isinstance(content, dict):
return json.dumps(content) if content else ""
else:
return str(content) if content is not None else ""
try:
return json.dumps(content) if content else ""
except TypeError:
return str(content) if content is not None else ""

def _get_metadata(
self, sample: Dict[str, Any], **additional_fields: Any
Expand Down

0 comments on commit 440c3bc

Please sign in to comment.