我想将数组中每个对象的图标重命名为大写,并将* configure afterScenario = """function(){ karate.call('classpath:api/users/delete/delete-user.feature', { user: userId }) """
替换为-
。
数组:
_
[
{time: 1566255600, summary: "Delno oblačno čez dan.", icon: "partly-cloudy-day", sunriseTime: 1566276904, sunsetTime: 1566328534, …},
{time: 1566342000, summary: "Pretežno oblačno čez dan.", icon: "partly-cloudy-day", sunriseTime: 1566363400, sunsetTime: 1566414810, …},
{time: 1566428400, summary: "Pretežno oblačno čez dan.", icon: "partly-cloudy-day", sunriseTime: 1566449896, sunsetTime: 1566501085, …},
{time: 1566514800, summary: "Pretežno oblačno čez dan.", icon: "partly-cloudy-day", ....}
]
答案 0 :(得分:2)
尝试
const daysForecast = forecast.daily.data.map(obj => { obj.icon = obj.icon.replace(/-/, "_").toUpperCase(); return obj });