| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::AutoCRUD::View::Json; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 462 | use 5.010; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 4 | 1 |  |  | 1 |  | 4 | use Moose; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 5 |  |  |  |  |  |  | extends 'App::AutoCRUD::View'; | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 4734 | use JSON::MaybeXS; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 62 |  | 
| 8 | 1 |  |  | 1 |  | 5 | use namespace::clean -except => 'meta'; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 12 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | has 'json_args' => ( is => 'bare', isa => 'HashRef', | 
| 11 |  |  |  |  |  |  | default => sub {{ pretty          => 1, | 
| 12 |  |  |  |  |  |  | allow_blessed   => 1, | 
| 13 |  |  |  |  |  |  | convert_blessed => 1 }} ); | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | sub render { | 
| 17 | 2 |  |  | 2 | 0 | 4 | my ($self, $data, $context) = @_; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # encode output | 
| 20 | 2 |  |  |  |  | 4 | my $json_maker = JSON::MaybeXS->new(%{$self->{json_args}}); | 
|  | 2 |  |  |  |  | 21 |  | 
| 21 | 2 |  |  |  |  | 83 | my $output     = $json_maker->encode($data); | 
| 22 |  |  |  |  |  |  |  | 
| 23 | 2 |  |  |  |  | 122 | return [200, ['Content-type' => 'application/json; charset=UTF-8'], | 
| 24 |  |  |  |  |  |  | [$output] ]; | 
| 25 |  |  |  |  |  |  | } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | 1; | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  |  | 
| 30 |  |  |  |  |  |  | __END__ | 
| 31 |  |  |  |  |  |  |  | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  |  |