1
我有以下数据集:你如何排除财产?
[
{
"py/object": "bit.ast.Node",
"_children": [
{
"py/object": "bit.ast.Node",
"_children": [
"main",
{
"py/object": "bit.ast.Node",
"_children": [
"args",
{
"py/object": "bit.ast.Node",
"_children": [
{
"py/object": "bit.ast.Node",
"_children": [
"str"
],
"source_column": 2,
"source_filename": "tests/fixture/hello.b",
"source_line": 1,
"tag": "type-named"
}
],
"base": {
"py/id": 10
},
"source_column": 2,
"source_filename": "tests/fixture/hello.b",
"source_line": 1,
"tag": "type",
"type": "array"
}
],
(等等...)
我怎么jq
排除该有它的所有对象的_children
财产?以_
开头的所有房产呢?
以下的无似乎工作:
jq 'map(del (._children))'
jq 'map(if has("_children") then del (._children) end)'
jq 'del(._children)'
jq 'del(.[]._children)'
jq 'del(.[]|._children)'
我不断收到类似的错误:
jq: error (at <stdin>:1): Cannot index string with string "_children"
请提供JSON的*完整*样品可以用作输入。 – chepner
@chepner我拥有的东西足以满足我的用例。 – Qix
@Qix - 如果没有看到更多的输入信息,就很难确定报告错误的原因。 – peak