JSON Configuration Migration Guide
February 11, 2026 · View on GitHub
Overview
ACAT has migrated from XML to JSON for configuration files. This guide explains the changes and how to migrate existing configurations.
Migrated Configuration Types
✅ Abbreviations Configuration
- Old Format:
Abbreviations.xml - New Format:
Abbreviations.json - POCO:
AbbreviationsJson(namespace:ACAT.Core.Configuration) - Validator:
AbbreviationsValidator(namespace:ACAT.Core.Validation)
JSON Structure
{
"abbreviations": [
{
"word": "btw",
"replaceWith": "by the way",
"mode": "Write"
}
]
}
Valid Mode Values
Write- Expand abbreviation as textSpeak- Speak the expansionNone- No expansion
Example
See /schemas/examples/abbreviations.example.json for a complete example.
✅ Pronunciations Configuration
- Old Format:
Pronunciations.xml - New Format:
Pronunciations.json - POCO:
PronunciationsJson(namespace:ACAT.Core.Configuration) - Validator:
PronunciationsValidator(namespace:ACAT.Core.Validation)
JSON Structure
{
"pronunciations": [
{
"word": "github",
"pronunciation": "git hub"
}
]
}
Example
See /schemas/examples/pronunciations.example.json for a complete example.
✅ Previously Migrated (from Ticket #7)
- Actuator Settings:
ActuatorSettings.json - Panel Configuration:
PanelConfig.json - Theme Configuration:
Theme.json
Backward Compatibility
All migrated configuration classes maintain backward compatibility with XML files:
- File Detection: The system checks for JSON files first, then falls back to XML if JSON is not found
- Automatic Format Detection: Based on file extension (
.jsonor.xml) - Transparent Loading: No code changes required in consuming code
Example File Lookup Order
For Abbreviations:
- Looks for
Abbreviations.jsonin resources directory - Looks for
Abbreviations.jsonin user directory - Falls back to
Abbreviations.xmlin resources directory - Falls back to
Abbreviations.xmlin user directory - Creates default
Abbreviations.jsonif none found
Migration Steps
Manual Migration
- Locate your existing XML configuration file
- Convert to JSON format using the examples as a template
- Save with
.jsonextension - The system will automatically use the JSON file
Using ConfigMigrationTool
The ConfigMigrationTool application can convert XML configurations to JSON automatically.
Features
Validation
All JSON configurations are validated using FluentValidation:
- Required fields are checked
- Data types are validated
- Enum values are verified
- Custom business rules are applied
Error Handling
- Invalid JSON: Falls back to defaults with error message
- Missing File: Creates default configuration
- Validation Failure: Falls back to defaults with detailed error messages
JSON Format Features
- Comments: Supports
//and/* */style comments - Trailing Commas: Allows trailing commas for easier editing
- Case-Insensitive: Property names are case-insensitive during deserialization
- Indented Output: Saved files are pretty-printed for readability
Code Examples
Loading Abbreviations
var abbreviations = new Abbreviations();
abbreviations.Load(); // Automatically tries JSON first, then XML
// Or specify a file
abbreviations.Load("/path/to/Abbreviations.json");
Saving Abbreviations
var abbreviations = new Abbreviations();
abbreviations.Add(new Abbreviation("btw", "by the way", AbbreviationMode.Write));
abbreviations.Save(); // Saves as JSON
Using JsonConfigurationLoader Directly
var loader = new JsonConfigurationLoader<AbbreviationsJson>(
new AbbreviationsValidator(),
logger
);
var config = loader.Load("/path/to/Abbreviations.json");
Testing
Comprehensive test coverage is provided in:
ACATCore.Tests.Configuration/AbbreviationsTests.csACATCore.Tests.Configuration/PronunciationsTests.cs
Run tests with:
cd src/Libraries/ACATCore.Tests.Configuration
dotnet test
TTS Engine Settings
TTS engine pronunciation file references have been updated:
- SAPI Engine:
SAPIPronunciations.json(was.xml) - TTS Client:
TTSPronunciations.json(was.xml)
Legacy XML files will still work due to backward compatibility.
Troubleshooting
"Configuration validation failed"
Check the application logs for specific validation errors. Common issues:
- Empty required fields
- Invalid enum values (e.g., mode must be "Write", "Speak", or "None")
- Malformed JSON syntax
"Configuration file not found"
The system will create a default configuration. Check:
- File path is correct
- File has read permissions
- File extension is
.jsonor.xml
"JSON parsing error"
Check JSON syntax:
- All brackets and braces are matched
- Strings are properly quoted
- No trailing commas at the end of arrays/objects (unless using comment-tolerant parser)
Future Migrations
Other configuration types may be migrated to JSON in future releases. The pattern established here will be followed:
- Create JSON POCO
- Create FluentValidation validator
- Update loader to support both JSON and XML
- Add comprehensive tests
- Update documentation
Related Files
- POCOs:
/src/Libraries/ACATCore/Configuration/ - Validators:
/src/Libraries/ACATCore/Validation/ - Tests:
/src/Libraries/ACATCore.Tests.Configuration/ - Examples:
/schemas/examples/ - JsonConfigurationLoader:
/src/Libraries/ACATCore/Utility/JsonConfigurationLoader.cs