Perl Requires Chilkat v11.0.0+
Perl
Copy JSON Object from one JSON Array to Another
See more JSON Examples
Demonstrates how to copy an object in a JSON array to another JSON array.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $arr1 = Chilkat2::JsonArray->new;
my $arr2 = Chilkat2::JsonArray->new;
my $s = '[{"a":1}, {"b":2}, {"c":3}]';
my $sEmpty = '[]';
$arr1->Load($s);
$arr2->Load($sEmpty);
my $jObj = Chilkat2::JsonObject->new;
$arr1->ObjectAt2(1, $jObj);
$arr2->AddObjectCopyAt(-1, $jObj);
print $arr2->Emit(), "\n";
# output is: [{"b":2}]