【发布时间】:2015-07-31 23:39:42
【问题描述】:
我有以下 json:
{
"vertices": [
{
"__cp": "foo",
"__type": "metric",
"__eid": "foobar",
"name": "Undertow Metrics~Sessions Created",
"_id": 45056,
"_type": "vertex"
},
...
]
"edges": [
...
我想实现这种格式:
{
"nodes": [
{
"cp": "foo",
"type": "metric",
"label": "metric: Undertow Metrics~Sessions Created",
"name": "Undertow Metrics~Sessions Created",
"id": 45056
},
...
]
"edges": [
...
到目前为止,我能够创建这个表达式:
jq '{nodes: .vertices} | del(.nodes[]."_type", .nodes[]."__eid")'
即将“顶点”重命名为“节点”并删除“_type”和“__eid”,如何重命名嵌套在 JSON 中更深层次的键?
【问题讨论】: