#!perl -w use strict; use JSON::XS; # Create a simple circular data structure: my $output; $output = ['foo']; $output->[1] = $output; my $json = JSON::XS->new->utf8->max_depth(100); use Data::Dumper; print Dumper $output; print $json->encode($output); __END__ json text or perl structure exceeds maximum nesting level (max_depth set too low?) at tmp.pl line 13.