#!/usr/bin/perl

use strict;
use warnings;

use JSON qw();

package Foo;

sub new {
    return bless {} => shift;
}

sub TO_JSON {
    return new Foo;
}

package main;

my $json = JSON->new()->convert_blessed(1)->pretty(1);
#print $json->backend(), "\n";
print $json->encode(new Foo);