package Puncheur::Plugin::JSON;
use 5.010;
use strict;
use warnings;
use JSON;
our @EXPORT = qw/res_json/;
sub res_json {
my ($self, $data) = @_;
state $json = JSON->new->ascii(1);
stat
# ditto.
};
my $body = $json->encode($data);
$body =~ s!([+<>])!$escape->{$1}!g;
my $user_agent = $self->req->user_agent || '';
# defense from JSON hijacking
if (
(!$s
&&
($self->req->method||'GET') eq 'GET')
{
my $content = "Your request may be JSON hijacking.\nIf you are not an attacker, please add 'X-Requested-With' header to each request.";