I need some help defining a type for a JSON file with the following format,
{
"UID_ABC1" : {
"name": "test",
"email": "test@whatever.com"
},
"UID_DEF2" : {
"name": "test2",
"email": "test2@whatever.com"
},
...,
"UID_XYZ3" : {
"name" : "test 7",
"email": "test7@whatever.com"
},
"globalConfig" : {
"isEnabled": true
}
}
There are an unknown number of UID key/value pairs but there is always just one globalConfig
object. I cannot change the format of the JSON. The UIDs are basically just randomly generated strings that I do not know ahead of time and the inner objects are just made up of standard fields that are trivial to type, so I am mainly concerned with the top level typing.
Something like this is close,
export interface MyJsonType {
[key: string]: MyType,
globalConfig: MyConfigType
}
But does not account for the multiple types. There is a syntax error complaining about MyConfigType.