Skip to content

Commit

Permalink
improved Mojo::JSON to generate smaller JSON by not escaping the "/" …
Browse files Browse the repository at this point in the history
…character
  • Loading branch information
kraih committed Aug 12, 2014
1 parent 5c4687d commit 5271482
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changes
@@ -1,5 +1,7 @@

5.28 2014-08-12
- Improved Mojo::JSON to generate smaller JSON by not escaping the "/"
character.

5.27 2014-08-11
- Added support for nested helpers.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/JSON.pm
Expand Up @@ -230,7 +230,7 @@ sub _encode_object {

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

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

0 comments on commit 5271482

Please sign in to comment.