RL',
# text
'html' => 'text/html; charset=utf-8',
'json' => 'application/json',
'js' => 'application/javascript',
'txt' => 'text/plain',
if( ! (eval "use JSON; 1")) {
eval "use JSON::PP; 1" or die "No implementation of JSON available";
warn __PACKAGE__.": Using PurePerl version of JSON (JSON::PP)";
}
# expects perl data structure
sub SendAsJSON {
my ($self, $obj, $options) = @_;
@_ = ($self, 'application/json', encode_json($obj), $options);
goto &SendBytes;
}