SubtitleEdit/subtitleedit · error · InvalidDataException
Failed to parse multiple-replace JSON at {path}: {ex.Message
Error message
Failed to parse multiple-replace JSON at {path}: {ex.Message} What it means
Wrapped exception thrown by MultipleReplaceLoader.ParseJson when System.Text.Json.JsonSerializer.Deserialize<CategoryImportExport> fails on the multiple-replace file content. The file was read successfully but is not valid JSON or does not map to the CategoryImportExport schema (the SE5 category/rule shape used by .template and .csv exports). The original exception is preserved as InnerException of an InvalidDataException with the path and original message.
Source
Thrown at src/seconv/Core/MultipleReplaceLoader.cs:130
rules.Add(rule);
}
}
}
return rules;
}
private static CategoryImportExport ParseJson(string content, string path)
{
try
{
var item = System.Text.Json.JsonSerializer.Deserialize<CategoryImportExport>(content,
new System.Text.Json.JsonSerializerOptions { PropertyNameCaseInsensitive = true });
return item ?? new CategoryImportExport();
}
catch (Exception ex)
{
throw new InvalidDataException($"Failed to parse multiple-replace JSON at {path}: {ex.Message}", ex);
}
}
// Flattens the SE5 category/rule shape (shared by the .template JSON and the CSV) into active
// rules, mapping the UI's MultipleReplaceType names to the XML SearchType names the apply loop
// expects: CaseInsensitive -> Normal, others by name.
private static List<Rule> LoadCategoryItemRules(CategoryImportExport item)
{
var rules = new List<Rule>();
if (item.Categories == null)
{
return rules;
}
foreach (var category in item.Categories)
{
if (category.Rules == null)
{View on GitHub (pinned to 17a9f07487)
Solutions
- Validate the JSON with a linter (e.g. `python -m json.tool file.json`) to find the syntax error.
- If the file is actually XML or CSV, rename it with the correct extension (.xml/.csv) so the loader picks the right parser.
- Re-export from the SE GUI (Tools > Multiple replace > export as .template) to get a valid file.
Defensive patterns
Strategy: try-catch
Try / catch
try { var rules = MultipleReplaceLoader.LoadRules(path); }
catch (InvalidDataException ex) when (ex.Message.Contains("Failed to parse multiple-replace JSON"))
{
// ex.InnerException has the JsonException with line/byte position
var jsonError = ex.InnerException;
// Report JSON parse error, suggest re-export or fix
} Prevention
- Validate JSON files with a JSON linter before using them.
- Use the correct file extension (.json/.template) so the loader picks the right parser.
- Re-export from the SE GUI to get schema-valid files rather than hand-editing JSON.
When it happens
Trigger: The multiple-replace file is selected as JSON (by .json/.template extension or content starting with '{') but is malformed JSON (trailing commas, unquoted keys, truncated), or has a valid JSON structure that doesn't match the CategoryImportExport type.
Common situations: Hand-editing the JSON and introducing a syntax error; a file exported by a different version of SE with a changed schema; truncated download/copy; mixing .json with a CSV body that starts with '{'.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse multiple-replace XML at {path}: {ex.Message}
- Failed to read multiple-replace file at {path}: {ex.Message}
- Multiple-replace file not found: {path}
- No Blu-Ray sup subtitles found in: {filePath}
- No PGS subtitles in MKV track #{track.TrackNumber}.
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/7fd8b6f166408528.
Report an issue: GitHub.