【发布时间】:2016-09-07 13:28:59
【问题描述】:
我正在解析一个 JSON 文件,并且我有一个数组数组 @AllArgumentsArray .. 带有此 AOA 的数组是我将遍历的 JSON 部分。示例 JSON 是:
{
name: "myThing",
value: {
UveVirtualMachineAgent: {
vm_name: "TuttyFruity"
}
}
},
现在我正在编写的函数将得到许多参数,例如
&GetAnalyticsDataInHash($json,'name','value,UveVirtualMachineAgent,vm_name');
sub GetAnalyticsDataInHash{
my @AllArgumentsArray; #The rest of the arguments in an array
my $decoded_json = $_[0];
for (my $i=1;$i<=$#_;$i++){
push @AllArgumentsArray, [ split /,/, $_[$i] ]; #split them and make array of arrays ..
}
print Dive($decoded_json, @AllArgumentsArray[0]), "\n";
}
The DumperShows that arrays are there in AOA .. 但我不确定如何在 Dive Function 中传递完整的数组?
DB<5> p Dumper @AllArgumentsArray
$VAR1 = [
'value',
'UveVirtualMachineAgent',
'vm_name'
];
$VAR2 = [
'value',
'get',
'this'
];
【问题讨论】:
-
当您调用
GetAnalyticsDataInHash($json,'name','value,UveVirtualMachineAgent,vm_name')时,您希望Dive的参数是什么? -
@AllArgumentsArray不可能包含您所说的内容。
标签: arrays json perl multidimensional-array