Skip to content

Commit

Permalink
For [GH #40] - cli_encode_json should care --binary too.
Browse files Browse the repository at this point in the history
  • Loading branch information
hkoba committed Jun 4, 2018
1 parent 6b876fd commit c9562dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Base/CLI_JSON.pm
Expand Up @@ -125,8 +125,13 @@ sub cli_invoke_sub_for_cmd {

sub cli_encode_json {
(my MY $self, my $obj) = @_;
my $codec = $self->{_cli_json} //= JSON->new->utf8->canonical;
Encode::_utf8_on(my $json = $codec->encode($obj));
my $codec = $self->{_cli_json} //= do {
my $js = JSON->new->canonical;
$js->utf8 unless $self->{binary};
$js;
};
my $json = $codec->encode($obj);
Encode::_utf8_on($json) unless $self->{binary};
$json;
}

Expand Down

0 comments on commit c9562dd

Please sign in to comment.