我希望我已经清楚地表达了我的问题。需要帮助查询,他们使用 JQ 解析多个 json 文件,其中每个文件中的结构是非线性的。该应用程序生成类似于此示例的配置数据。每个文件可以有零个或多个 DualEndPoint 或 Local 对象。我需要能够在“用户”属性中查询特定用户并插入新密码以重新提交回 api。对于 DualEndPoints,嵌套对象名称是可变的,因此无法在查找“用户”属性时对这些值进行编码。
如果找到特定用户的匹配项,则返回仅插入该用户的新密码的整个结构。在示例中,查询 user1 将返回整个 PROFILE1 和 PROFILE2,但不返回 PROFILE3,因为它不包含 user1 凭据。
{
"PROFILE1": {
"Type": "ConnectionProfile:FileTransfer:DualEndPoint",
"WorkloadAutomationUsers": [
"*"
],
"VerifyBytes": true,
"TargetAgent": "sqlrptvmjhbpr01",
"TargetCTM": "Production",
"Endpoint:Src:Local_0": {
"Type": "Endpoint:Src:Local",
"User": "user1",
"Port": "0",
"OsType": "Windows",
"HostName": "Local",
"Password": "*****",
"HomeDirectory": "/user1homedir"
},
"Endpoint:Dest:SFTP_1": {
"Type": "Endpoint:Dest:SFTP",
"User": "user2",
"HostName": "server2",
"Password": "*****",
"HomeDirectory": "/user2homedir"
}
},
"PROFILE2": {
"Type": "ConnectionProfile:FileTransfer:Local",
"WorkloadAutomationUsers": [
"*"
],
"VerifyBytes": true,
"User": "user1",
"VerifyDestination": true,
"OsType": "Windows",
"HostName": "Local",
"Password": "*****",
"TargetAgent": "server1",
"TargetCTM": "Production"
},
"PROFILE3": {
"Type": "ConnectionProfile:FileTransfer:Local",
"WorkloadAutomationUsers": [
"*"
],
"VerifyBytes": true,
"User": "user3",
"OsType": "Windows",
"HostName": "Local",
"Password": "*****",
"HomeDirectory": "/user3hoemdir",
"TargetAgent": "server2",
"TargetCTM": "Production"
}
}