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

JSON AppendArray2 Example

Demonstrates the AppendArray2 function.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $json = Chilkat2::JsonObject->new;
$json->Load('{ "name": "John", "marbles": 100 }');

# Append an empty array named "xyz"
my $jarr = Chilkat2::JsonArray->new;
$json->AppendArray2('xyz', $jarr);

print $json->Emit(), "\n";
# Expected output is:   {"name":"John","marbles":100,"xyz":[]}

# Add elements to the array.
$jarr->AddStringAt(-1, 'hello');
$jarr->AddIntAt(-1, 256);

print $json->Emit(), "\n";
# Expected output is:  {"name":"John","marbles":100,"xyz":["hello",256]}