I am working with a config.json
file.
{
"profiler": {
"port": 8001,
"profilerCache": {
"allowedOriginsRegex": ["^http:\/\/localhost:8080$", "i"]
}
},
"database": {
"uri": "mongodb+srv://...",
"dbName": "profiler",
"collectionName": "profiles"
}
}
During the build process, I need to ensure that the JSON structure matches my defined interface.
export interface Config {
port: number
profilerCache: {
allowedOriginsRegex: [string, string]
}
database: {
uri: string
dbName: string
collectionName: string
}
}
What is the most straightforward way to enforce type safety for my JSON files?