我有一个JSON对象
{
"0_documentation": {
"accountId": "The 12 digit AWS Account ID for the account",
"alias": "Friendly name used to refer to this account (think name input in ssh-with-role)",
"key": "This is the identifier you use for the account config, format: $domain.$realm.$service.$relativeId",
"region": "The primary region where resources in this account are stored. Must be a valid AWS region",
"region_partition": "This is ARN region partition (https://tiny.amazon.com/a51f4mku), this is usually a boundary of admin tools etc",
"stage": "The deployment stage this account supports - alpha, beta, gamma, prod",
"type": "The type of service supported by this account - service (single service stack - used in alphas), general (service account), canary, console"
},
"accounts": {
"alpha.us-east-1.cambridgeuseraccount": {
"accountId": "84624",
"alias": "alpha",
"region": "us-east-1",
"region_partition": "aws",
"stage": "alpha",
"type": "service"
},
"beta.us-east-1.cambridgeuseraccount": {
"accountId": "85236",
"alias": "beta",
"region": "us-east-1",
"region_partition": "aws",
"stage": "beta",
"type": "service"
},
"prod.us-east-1.cambridgeuseraccount" : {
"accountId": "85536",
"alias": "beta",
"region": "us-east-1",
"region_partition": "aws",
"stage": "prod",
"type": "service"
},
"prod.eu-west-1.cambridgeuseraccount" : {
"accountId": "128790",
"alias": "beta",
"region": "us-east-1",
"region_partition": "aws",
"stage": "prod",
"type": "service"
}
}
}
我想提取属性帐户以“ prod”开头的所有帐户ID。 例如,我要使用accountIdsprod.us-east-1.cambridgeuseraccount
tand prod.eu-west-1.cambridgeuseraccount
我想要预期的输出[128790 , 85536]
作为上述JSON的输出
[我想要一个JSONPath查询,我已经尝试过
$.[?(@.accounts =~ /prod.*?/i)]
但是我没有得到任何结果
我正在关注此站点https://github.com/json-path/JsonPath作为参考
我有一个JSON对象{“ 0_documentation”:{“ accountId”:“该账户的12位AWS账户ID”,“ alias”:“用于引用此账户的友好名称(请以ssh-with输入名称) -...
我认为$.[?(@.accounts =~ /prod.*?/i)]
无效。在“放心”中,“ JSON路径”语法使用Groovy's GPath