Sample code for 30+ languages & platforms
Perl Requires Chilkat v11.4.0+

Example: JsonObject.NewArrayOf method

See more JSON Examples

Demonstrates the NewArrayOf method.

Chilkat Perl Downloads

Chilkat2 Perl
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"
#   ]
# }