json.pm 455 B

123456789101112131415161718192021222324
  1. package Trog::Renderer::json;
  2. use strict;
  3. use warnings;
  4. no warnings 'experimental';
  5. use feature qw{signatures state};
  6. use JSON::MaybeXS;
  7. =head1 Trog::Renderer::json
  8. Render JSON. Rather than be templated, we just run the input thru the encoder.
  9. =cut
  10. sub render (%options) {
  11. my $code = delete $options{code};
  12. my $headers = delete $options{headers};
  13. my $body = encode_json(\%options);
  14. return [$code, [$headers], [$body]];
  15. }
  16. 1;