我的输入可能是:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>UserTriggerHandler_Test</members>
<members>UserTriggerHandasdler_Test</members>
<name>ApexClass</name>
</types>
<version>52.0</version>
</Package>
或者
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>UserTriggerHandasdler_Test</members>
<name>ApexClass</name>
</types>
<version>52.0</version>
</Package>
这些的 Xp 值为:
{
"Package": {
"@xmlns": "http://soap.sforce.com/2006/04/metadata",
"types": {
"members": "UserTriggerHandasdler_Test",
"name": "ApexClass"
},
"version": "52.0"
}
}
和
{
"Package": {
"@xmlns": "http://soap.sforce.com/2006/04/metadata",
"types": {
"members": ["UserTriggerHandler_Test", "UserTriggerHandasdler_Test"],
"name": "ApexClass"
},
"version": "52.0"
}
}
分别。
我正在尝试将输入传递给这个函数。
classsvalue=`cat manifest/package.xml | xq . | jq '.Package.types | if type=="array" then .[] else . end | select(.name=="ApexClass") |select(.members!="Test")|.members | join(",")'`
echo $classsvalue
但它失败了,因为join(",")
. 我想强制jq
总是返回数组中的成员。这可能吗?
我期待分别输出"UserTriggerHandasdler_Test"
和输出"UserTriggerHandasdler_Test,UserTriggerHandasdler_Test"
。