#!perl -w use strict; use JSON::XS 'encode_json'; print encode_json({foo=>'bar'}); my $j=JSON::XS->new;$j->convert_blessed(1) print $j->encode({foo=>qr/bar/}); sub Regexp::TO_JSON{qq($_[0])}"