[英]nested objects with arbitrary keys to key-value objects with jq
There is an json object with n nested objects, where the key ist arbitrary and the nested objects have all the same structure. 有一个带有n个嵌套对象的json对象,其中任意键和嵌套对象都具有相同的结构。
Example: 例:
{
"albert":{
"age": 35
},
"sarah":{
"age": 33
},
"otto":{
"age":27
}
}
with jq the output should be an array and look like this: 与jq输出应该是一个数组,看起来像这样:
[
{"name":"albert","age":35},
{"name":"sarah"","age":32},
{"name":"otto","age":27},
]
Can somebody help me? 有人可以帮我吗?
Thank you, 谢谢,
to_entries
| map( {name: .key, age: .value.age} )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.