mirror of
https://github.com/mikefarah/yq.git
synced 2026-09-01 14:14:52 +08:00
Can use expressions in slice #1419
This commit is contained in:
@@ -37,6 +37,15 @@ var sliceArrayScenarios = []expressionScenario{
|
||||
"D0, P[], (!!seq)::- dog\n- frog\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "Inserting into the middle of an array",
|
||||
subdescription: "using an expression to find the index",
|
||||
document: `[cat, dog, frog, cow]`,
|
||||
expression: `(.[] | select(. == "dog") | key + 1) as $pos | .[0:($pos)] + ["rabbit"] + .[$pos:]`,
|
||||
expected: []string{
|
||||
"D0, P[], (!!seq)::- cat\n- dog\n- rabbit\n- frog\n- cow\n",
|
||||
},
|
||||
},
|
||||
{
|
||||
skipDoc: true,
|
||||
document: `[[cat, dog, frog, cow], [apple, banana, grape, mango]]`,
|
||||
|
||||
Reference in New Issue
Block a user