I am newbie in typescript so not really good in syntax.
My requirement is I want to get some specific elment from json file in typescript.
Following is piece of code that I am trying here.
Json file
{
"Description": "data",
"data_list": {
"example1": {
"description": "example1",
"anothermap":{
"a": "1",
"b": "2"
}
},
"example2": {
"description": "example2"
}
}
}
Typescript file
import * as test from '../test.json';
export class Demo extends cdk.Stage {
constructor(scope: cdk.Construct, id: string, name: string) {
super(scope, id);
#const tskData = test.data_list['example1'];
const tskData = test.data_list[name];
}
in the above example when I try to call json value using literals then it works but not with varible. I can't use any literal here becuase what system needed will come as input.
Following is the error that I am getting it
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '
Any help on this would be appriciated