JSON Conflict Solver
Resolve complex JSON Git conflicts with a single click.
Merging JSON files (especially i18n or configuration files) during Git conflicts is often painful. Standard text-based merge tools break JSON syntax. This extension parses the conflicting blocks, repairs the broken JSON structure, and performs a deep merge to preserve keys from both branches.
✨ Features
- 🧠 Smart Deep Merge: Uses
lodash.merge to combine objects recursively. It preserves unique keys from both Current and Incoming changes instead of simply overwriting them.
- Rx Auto-Repair Syntax: Automatically fixes broken JSON syntax caused by Git conflict markers (
<<<<<<<, =======, >>>>>>>) using jsonrepair.
- 📂 Batch Processing: Merge all JSON files in a specific folder at once.
- ⚡ One-Click Action: Integrated directly into the Editor Title menu.
🚀 How to Use
1. Resolve Current File
When you open a JSON file with Git conflicts:
- Look for the Merge icon
$(git-merge) in the editor title bar (top right).
- Click it to instantly resolve conflicts in the active file.
2. Resolve Entire Folder (Batch)
If you have multiple conflicting files in a directory (e.g., src/locales):
- Open any file inside that project.
- Click the Folder icon
$(folder-library) in the editor title bar.
- Confirm or edit the target folder path (e.g.,
src/locales) in the input box.
- The extension will scan and resolve conflicts for all
.json files in that directory.
Note: You can also right-click a folder in the Explorer sidebar and select "Auto Merge JSON Conflicts in Folder".
💡 How it Works
Unlike standard text mergers, this extension:
- Extracts the
Current (HEAD) and Incoming code blocks.
- "Repairs" them into valid JSON objects (adding missing braces/commas).
- Merges the two objects:
- Objects: Deeply merged (keys from both sides are kept).
- Arrays: Overwritten by Incoming changes (default behavior).
- Strings/Values: Overwritten by Incoming changes.
📦 Requirements
- VS Code 1.70.0 or higher.
🔧 Extension Settings
Currently, this extension works out-of-the-box with no configuration required.
📝 Release Notes
0.0.1
- Initial release.
- Support for single file smart merge.
- Support for batch folder merge via input box.
Enjoying this extension? Please leave a review on the Marketplace!
JSON Conflict Solver
一键解决复杂的 JSON Git 冲突。
在 Git 冲突期间合并 JSON 文件(尤其是 i18n 或配置文件)通常很痛苦。标准的基于文本的合并工具会破坏 JSON 语法。此扩展会解析冲突块,修复损坏的 JSON 结构,并执行深度合并以保留两个分支的键。
✨ 特性
- 🧠 智能深度合并: 使用
lodash.merge 递归合并对象。它会保留 Current 和 Incoming 更改中的唯一键,而不是简单地覆盖它们。
- 🔧 自动修复语法: 使用
jsonrepair 自动修复由 Git 冲突标记(<<<<<<<、=======、>>>>>>>)导致的损坏 JSON 语法。
- 📂 批量处理: 一次性合并特定文件夹中的所有 JSON 文件。
- ⚡ 一键操作: 直接集成到编辑器标题菜单中。
🚀 使用方法
1. 解决当前文件
当你打开一个包含 Git 冲突的 JSON 文件时:
- 在编辑器标题栏(右上角)查找 Merge 图标
$(git-merge)。
- 点击它即可立即解决活动文件中的冲突。
2. 解决整个文件夹(批量)
如果你在一个目录中有多个冲突文件(例如 src/locales):
- 打开该项目内的任何文件。
- 点击编辑器标题栏中的 Folder 图标
$(folder-library)。
- 在输入框中确认或编辑目标文件夹路径(例如
src/locales)。
- 扩展将扫描并解决该目录中所有
.json 文件的冲突。
注意: 你也可以在资源管理器侧边栏中右键单击文件夹,然后选择 "Auto Merge JSON Conflicts in Folder"。
💡 工作原理
与标准文本合并器不同,此扩展:
- 提取
Current(HEAD)和 Incoming 代码块。
- 将它们"修复"为有效的 JSON 对象(添加缺失的大括号/逗号)。
- 合并两个对象:
- 对象: 深度合并(保留双方的键)。
- 数组: 被 Incoming 更改覆盖(默认行为)。
- 字符串/值: 被 Incoming 更改覆盖。
📦 要求
🔧 扩展设置
目前,此扩展开箱即用,无需配置。
📝 发布说明
0.0.1
- 初始版本。
- 支持单文件智能合并。
- 支持通过输入框批量合并文件夹。
喜欢这个扩展? 请在 Marketplace 上留下评价!