Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| if file_exists: | ||
| for key, value in new_data.items(): | ||
| if key in existing_data: | ||
| existing_data[key] = value |
There was a problem hiding this comment.
Overwrite nested JSON objects instead of merging
When the target file exists, the loop replaces an entire value whenever the top-level key is present. If that value is itself a dictionary, providing a partial update will clobber unspecified nested keys. For example, an existing document { "settings": { "theme": "dark", "lang": "en" } } updated with new_data={"settings": {"lang": "fr"}} results in {"settings": {"lang": "fr"}}, losing theme. This contradicts the docstring’s promise to preserve the original structure and can silently drop data. A recursive merge is needed to update only the provided nested keys.
Useful? React with 👍 / 👎.
Summary
update_json_filehelper to merge dictionaries into JSON filesTesting
https://chatgpt.com/codex/tasks/task_e_68de63a163b8832693cc779de228b41e