JSON parse error: expected value at line 1 - cc-switch
Quick fix
Upgrade cc-switch to fix JSON corruption from concurrent writes, and add custom fields to general config so a switch cannot overwrite them.
Symptom
Section titled “Symptom”JSON 解析错误: C:\Users\soham\.gemini\settings.json: expected value at line 1 column 1JSON parse error: C:\Users\soham\.gemini\settings.json: expected value at line 1 column 1
When switching or adding a provider in cc-switch, a concurrent failover or hot switch can leave the UI state out of sync with `settings.json`, or even corrupt the file to empty, producing a JSON parse error. Separately, cc-switch overwrites the target app's `settings.json` wholesale from a snapshot by default, silently discarding non-provider custom fields such as `tui` and `hooks`.
v3.13.0 fixed the state confusion from concurrency and hardened JSON parse tolerance, but the wholesale overwrite that loses custom fields remains (in v3.18.0, a lost `tui` makes Claude Code go full screen). You have to inject the fields you need to keep through the general config feature.
Upgrade cc-switch to v3.13.0 or newer to fix the `settings.json` state confusion and JSON parse error from concurrent switching.
For custom fields such as `tui` and `hooks` being overwritten on a switch, add the JSON fragment you need to keep under 通用配置 (general config) at the top left of the cc-switch UI.
// cc-switch 通用配置{"tui": "default"}
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- The JSON parse error persists after upgrading to v3.13.0. What now?
- Check whether `settings.json` was corrupted to an empty file, and restore it by hand if so. If it still errors, reopen the issue with logs.
- Adding or switching provider loses my custom hooks, tui, and similar config. What now?
- cc-switch overwrites the config file wholesale. Put the general config fragments you need to keep into 通用配置 (general config) so they are written back quickly.
- Could there be an option to hide the tray icon, or fix duplicate tray icons?
- Duplicate icons from reopening on Windows is a known bug under repair, and a minimise-to-tray toggle is planned for settings in future.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.