Skip Menu |

This queue is for tickets about the JSON CPAN distribution.

Report information
The Basics
Id: 16716
Status: resolved
Priority: 0/
Queue: JSON

People
Owner: Nobody in particular
Requestors: alexmv [...] bestpractical.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Option to use single quotes for JSON::Converter output
From: Alex Vandiver <alexmv [...] bestpractical.com>
To: bug-JSON [...] rt.cpan.org
Date: Fri, 23 Dec 2005 20:03:49 -0500
Heya, The attached patch makes the QuotApos option respected by JSON::Converter, so that it can *output* single-quoted JSON as well as parsing it. - Alex

Message body is not shown because sender requested not to inline it.

Thanks to your patch. Sorry, the patch is not scheduled to be applied under the present situation because of complexity of processing and JSON format. However, the function might be achieved by some methods(below) in the future version. alternatives: { local $^W = undef; my %esc = ( "\n" => '\n', "\r" => '\r', "\t" => '\t', "\f" => '\f', "\b" => '\b', "'" => '\\\'', "\\" => '\\\\', ); 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; return "'" . $arg ."'"; }; $js = objToJson($obj); print $js, "\n"; }