# Example Perl code to test JSON handling with Cpanel::JSON::XS
use strict;
use warnings;
use Cpanel::JSON::XS;
use Test::More;
my $json = Cpanel::JSON::XS->new->pretty;
sub encode_json {
my ($data) = @_;
return $json->encode($data);
}
sub decode_json {
my ($json_str) = @_;
return $json->decode($json_str);
}
# Test encode_json function
my $data = { key1 => 'value1', key2 => 'value2' };
my $json_string = encode_json($data);
is($json_string, '{"key1":"value1","key2":"value2"}', 'encode_json works correctly');
# Test decode_json function
my $decoded_data = decode_json($json_string);
is_deeply($decoded_data, $data, 'decode_json works correctly');
done_testing();
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?