[Jifty-commit] r3078 - jifty/trunk/lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Apr 1 08:41:41 EDT 2007
Author: dpavlin
Date: Sun Apr 1 08:41:39 2007
New Revision: 3078
Modified:
jifty/trunk/lib/Jifty/JSON.pm
Log:
fix handling of multi-line data when encoded in JSON -- they should never
wrap over multiple lines in generated output
Modified: jifty/trunk/lib/Jifty/JSON.pm
==============================================================================
--- jifty/trunk/lib/Jifty/JSON.pm (original)
+++ jifty/trunk/lib/Jifty/JSON.pm Sun Apr 1 08:41:39 2007
@@ -73,7 +73,13 @@
local $JSON::Syck::SingleQuote = $args->{singlequote};
local $JSON::Syck::ImplicitUnicode = 1;
- JSON::Syck::Dump($obj);
+ my $json = JSON::Syck::Dump($obj);
+ if (! $args->{singlequte}) {
+ $json =~ s/\n\n\n/\\n/gs; # fix syck bug
+ $json =~ s/\n/\\n/gs; # just to be safe
+ $json =~ s/\r/\\r/gs;
+ }
+ return $json;
}
# We should escape double-quotes somehow, so that we can guarantee
@@ -101,7 +107,7 @@
local *JSON::Converter::_stringfy = sub {
my $arg = shift;
$arg =~ s/([\\\n'\r\t\f\b])/$esc{$1}/eg;
- $arg =~ s/([\x00-\x07\x0b\x0e-\x1f])/'\\u00' . unpack('H2',$1)/eg;
+ $arg =~ s/([\x00-\x07\x0b\x0e-\x1f])/'\\u00' . unpack('H2',$1)/egs;
return "'" . $arg ."'";
};
return JSON::objToJson($obj, $args);
More information about the Jifty-commit
mailing list