You are very close! Few things:
null not 'null'- After working with the pipe, you will work with the results of the first expression
- like
null, is truenot a string ( == truealso redundant)
jmespath.org , . json, :
{
"DistributionList": {
"Items": [
{
"Id": "foo",
"Aliases": {
"Quantity": 1,
"Items": [
"cname.cdn.mycompany.com"
]
}
},
{
"Id": "bar",
"Aliases": {
"Quantity": 1,
"Items": [
"cname.cdn.othercompany.com"
]
}
},
{
"Id": "baz",
"Aliases": {
"Quantity": 0
}
}
]
}
}
. , , - :
DistributionList.Items[?Aliases.Items!=null]
Items <<28 > . , , :
[
{
"Id": "foo",
"Aliases": {
"Quantity": 1,
"Items": [
"cname.cdn.mycompany.com"
]
}
},
{
"Id": "bar",
"Aliases": {
"Quantity": 1,
"Items": [
"cname.cdn.othercompany.com"
]
}
}
]
, DistributionList.Items.
, CNAME. == true.
[?contains(Aliases.Items, 'cname.cdn.mycompany.com')]
, :
DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, 'cname.cdn.mycompany.com')]
- :
[
{
"Id": "foo",
"Aliases": {
"Quantity": 1,
"Items": [
"cname.cdn.mycompany.com"
]
}
}
]
, , .Id . , , [0].
DistributionList.Items[?Aliases.Items!=null] | [?contains(Aliases.Items, 'cname.cdn.mycompany.com')].Id | [0]
, !
"foo"