-
Notifications
You must be signed in to change notification settings - Fork 15.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
community: fixes json loader not getting texts with json standard #27327
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Tests failing due to how the new implementation handles string content. |
440c3bc
to
505d7f7
Compare
505d7f7
to
e6c60c6
Compare
Fixed the string content problem. And I also modified file_path in test_json_loader.py, to make sure tests will work on windows. |
return json.dumps(content) if content else "" | ||
else: | ||
return str(content) if content is not None else "" | ||
match content: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
match statements were introduced in 3.10, but we support 3.9+. Please revert to if/elif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine but in general would recommend against changing both of these things together!
This PR fixes JSONLoader._get_text not converting objects to json string correctly.
If an object is serializable and is not a dict, JSONLoader will use python built-in str() method to convert it to string. This may cause object converted to strings not following json standard. For example, a list will be converted to string with single quotes, and if json.loads try to load this string, it will cause error.