Perl Requires Chilkat v11.4.0+
Chilkat2 Perl
Example: JsonObject.NewArrayOf method
See more JSON Examples
Demonstrates theNewArrayOf method.
Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $big_cats = '["lion","tiger","leopard","jaguar","cheetah","snow leopard","clouded leopard","cougar","puma","panther"]';
my $json = Chilkat2::JsonObject->new;
$json->UpdateString('test', 'abc');
my $success = $json->NewArrayOf('big_cats', $big_cats);
if (!$success) {
print $json->LastErrorText, "\n";
exit;
}
$json->EmitCompact(0);
print $json->Emit(), "\n";
# Result:
# {
# "test": "abc",
# "big_cats": [
# "lion",
# "tiger",
# "leopard",
# "jaguar",
# "cheetah",
# "snow leopard",
# "clouded leopard",
# "cougar",
# "puma",
# "panther"
# ]
# }