Change value of property based on path in typescript

Viewed 13

I have an object that has a structure like the following:

{ 
 "Configuration" : 
 { "ImportPath" : "C:\\Temp", 
   "ImportSettings" : { "Style" : "Flat" } 
 }
}

The I have a function that takes this object as a parameter and the JSON Path of the property. So in case of the ImportStyle the path would be:

"Configuration.ImportSettings.Style"

How can I change the value of the property based on the given path? Something like:

public static ChangeProperty(config : any, path : string, newValue : string) : boolean{
     config[path] = newValue;
}
0 Answers
Related