Perl Requires Chilkat v11.0.0+
Chilkat2 Perl
JSON AppendObject2 Example
Demonstrates the AppendObject2 function.Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $json = Chilkat2::JsonObject->new;
$json->Load('{ "name": "John", "marbles": 100 }');
# Append an empty object named "addr"
my $jObj = Chilkat2::JsonObject->new;
$json->AppendObject2('addr', $jObj);
print $json->Emit(), "\n";
# Expected output is: {"name":"John","marbles":100,"addr":{}}
# Add members to the object.
$jObj->AppendString('street', '1200 Elm St.');
$jObj->AppendString('city', 'Springfield');
$jObj->AppendInt('zip', 60606);
print $json->Emit(), "\n";
# Expected output is: {"name":"John","marbles":100,"addr":{"street":"1200 Elm St.","city":"Springfield","zip":60606}}