我的 json 内容存储在一个文件中:
{
"vms": [
{
"component": "pgdb",
"count": "1",
"endpoints": "80:8080,5432:5432"
},
{
"component": "mq",
"count": "1",
"endpoints": "80:8080,5672:5672,15672:15672"
},
{
"component": "ucms",
"count": "1",
"endpoints": "80:80,8080:8080"
},
{
"component": "wsgw",
"count": "1",
"endpoints": "8080:8080,9093:9093"
}
]
}
in irb :
require 'json'
require 'Siren'
json = File.read('c:\\stack1.json')
irb(main):022:0> Siren.query "$.vms..[? @.component == ucms ]", json
=> []
我正在尝试起草一个查询,该查询将搜索组件名称并返回端点的值。任何帮助/指针将不胜感激。
谢谢