$ ./file.sh
[
{
"branch": [
"one/",
"two/"
],
"stack": ""
}
]
[
{
"branch": [
"one/",
"two/"
],
"stack": ""
}
]
[
"one/",
"two/"
]
[
"one/",
"two/"
]
[
[
"one/"
]
]
Error evaluating JMESPath expression: invalid type for: [one/ two/], expected: []functions.JpType{"string"}
Last active
September 28, 2023 17:29
-
-
Save psydvl/5c40a1ddd5bcbd601fe3284e013d2c05 to your computer and use it in GitHub Desktop.
JMESPath strange behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
go install github.com/jmespath-community/jp@latest | |
# shellcheck disable=SC2089 | |
data='[{ | |
"stack": "", | |
"branch": [ | |
"one/", | |
"two/" | |
] | |
} | |
]' | |
echo "$data" | jp "[]" | |
echo "$data" | jp "[?stack=='']" | |
echo "$data" | jp "[] .branch[]" | |
echo "$data" | jp "[?stack==''].branch[]" | |
echo "$data" | jp "[] .branch[?starts_with(@, 'one')]" | |
echo "$data" | jp "[?stack==''].branch[?starts_with(@, 'one')]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment