Skip to content

Commit

Permalink
a few more Mojo::JSON tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 17, 2014
1 parent cd15595 commit 7947c2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Mojo/JSON.pm
Expand Up @@ -259,7 +259,7 @@ sub _encode_object {

sub _encode_string {
my $str = shift;
$str =~ s!([\x00-\x1f\x{2028}\x{2029}\\"/\b\f\n\r\t])!$REVERSE{$1}!gs;
$str =~ s!([\x00-\x1f\x{2028}\x{2029}\\"/])!$REVERSE{$1}!gs;
return "\"$str\"";
}

Expand Down
5 changes: 3 additions & 2 deletions t/mojo/json.t
Expand Up @@ -131,8 +131,9 @@ is b($bytes)->decode('UTF-8'), "[\"hello\\u0003\x{0152}world\x{0152}!\"]",
'encode ["hello\x{0003}\x{0152}world\x{0152}!"]';
$bytes = $json->encode(["123abc"]);
is $bytes, '["123abc"]', 'encode ["123abc"]';
$bytes = $json->encode(["\a\b/\f\r"]);
is $bytes, '["\\u0007\\b\/\f\r"]', 'encode ["\a\b/\f\r"]';
$bytes = $json->encode(["\x00\x1f \a\b/\f\r"]);
is $bytes, '["\\u0000\\u001F \\u0007\\b\/\f\r"]',
'encode ["\x00\x1f \a\b/\f\r"]';

# Encode object
$bytes = $json->encode({});
Expand Down

0 comments on commit 7947c2e

Please sign in to comment.