local tail
local element
local new
+ local string_re
+ string_re='^"(.*)"$'
tail=()
while read -r element; do
- tail+=("$element")
- done < <(jq -r '.[1:][]' <<< "$array")
+ if [[ "$element" =~ $string_re ]]; then
+ tail+=("${BASH_REMATCH[1]}")
+ else
+ tail+=("$element")
+ fi
+ done < <(jq -c '.[1:][]' <<< "$array")
if ! new=$(json_array "${tail[@]}"); then
return 1
End
It "removes an object from the head of the array"
- When call json_array_tail '[{}, {"hello": "world"}]'
- The stdout should equal '[{"hello": "world"}]'
+ When call json_array_tail '[{}, {"hello":"world"}]'
+ The stdout should equal '[{"hello":"world"}]'
The status should equal 0
End
End
End
It "splits a string array to lines"
- When call json_array_to_lines '["hello", "world"]'
+ When call json_array_to_lines '["hello","world"]'
The first line of stdout should equal "hello"
The second line of stdout should equal "world"
The status should equal 0