I can not get item from an array in the configuration file.
{
"crawlerConfigurations":{
"ClickDelay": 100,
"TypeDelay": 200,
"Selectors": {
"Search": [
{
"SearchInitUrl": "https://www.wukong.com"
}
]
}
}
I'm trying to get the SearchInitUrl
prop of first Search item, and I'm using
config.get(`crawlerConfigurations.Selectors.Search[0].SearchInitUrl`)
config.get(`crawlerConfigurations.Selectors.Search.[0].SearchInitUrl`)
did not work
Hope someone would help, thanks in advance.
I don't recommend arrays in configs because they're treated as a whole from an override perspective (like strings are arrays of characters, and you can't override a substring).
That said, sometimes you want that behavior. When you do, the following should work
config.get('crawlerConfigurations.Selectors.Search.0.SearchInitUrl');
The number zero (0) is a variable name like the other names in the path. Not sure why the original question had a ':' in the string, but that was a bug.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.