Json 使用jq从数学系谱项目中筛选数据集

Json 使用jq从数学系谱项目中筛选数据集,json,jq,Json,Jq,使用此Json数据集 { "nodes": [ { "students": [], "advisors": [ 258 ], "name": "Archie Higdon", "school": "Iowa State University", "subject": "74—Mechanics of deformable solids", "thesis": "Stresses in

使用此Json数据集

{
  "nodes": [
    {
      "students": [],
      "advisors": [
        258
      ],
      "name": "Archie Higdon",
      "school": "Iowa State University",
      "subject": "74—Mechanics of deformable solids",
      "thesis": "Stresses in Moderately Thick Rectangular Plates",
      "country": "UnitedStates",
      "year": 1936,
      "id": 2
    },
    {
      "students": [],
      "advisors": [
        258
      ],
      "name": "Donald Hill Rock",
      "school": "Iowa State University",
      "subject": null,
      "thesis": "Finite Strain Analysis in Elastic Theory",
      "country": "UnitedStates",
      "year": 1939,
      "id": 3
    },
    {
      "students": [],
      "advisors": [
        258
      ],
      "name": "William B. Stiles",
      "school": "Iowa State University",
      "subject": null,
      "thesis": "Solutions of Clamped Plated Problems by Means of Functions Derived from Membrane Characteristic Functions",
      "country": "UnitedStates",
      "year": 1945,
      "id": 6
    }
]

}

我想知道如何使用jq来找到那些毕业于佐治亚理工大学的学生,他们的学生名单不是空的?我想找到所有毕业于佐治亚理工学院的学生,他们自己给学生提供建议

假设简化的json是这样的,其中有些值与您提到的条件相匹配

{
  "nodes": [
    { "students": [2, 3], "advisors": [],  "name": "Person 1", "school": "Georgia Tech", "id": 1 },
    { "students": [],     "advisors": [1], "name": "Person 2", "school": "Georgia Tech", "id": 2 },
    { "students": [],     "advisors": [1], "name": "Person 3", "school": "Georgia Tech", "id": 3 }
  ]
}
您可以使用

您可以将节点修剪为具有非空学生且具有

.nodes |= map( select( .students | length > 0 ) )
您可以将这些条件与

.nodes |= map( 
   select( (.school == "Georgia Tech") and (.students | length > 0) ) 
)

除了遵循基本指导原则外,SO上的问题通常包括一些您尝试过的策略或计划的指示。另外,你的例子似乎没有包括任何有学生的人,或者确实没有任何来自佐治亚理工学院的人。谢谢。这正是我想要的。
.nodes |= map( 
   select( (.school == "Georgia Tech") and (.students | length > 0) ) 
)