2016-06-08 86 views

回答

1
  1. 在这种情况下,你也可以使用startswith/1
  2. 您还可以使用地图/ 1,选择/ 1,而不是/ 0
  3. 可以使用更新就地“米”槽| =

因此:

.m |= map(select(startswith("bad-") | not)) 

生产:

{ 
    "m": [ 
    "ok", 
    "also-ok" 
    ] 
} 
0

该解决方案使用正则表达式和reduce操作:

reduce .[] as $item ([]; if ($item | test("^bad-")) then . else . + [$item] end)

事情我了解到:

  1. reduce操作
  2. 你可以管 '子项',通过过滤器(以上$item | test("^bad")