use UTF8 JSON encoding and decoding universally

fixed: Import/Export of packages with international text is broken
This commit is contained in:
Graham Knop 2008-04-01 14:42:20 +00:00
parent 35bfeac0ef
commit 9ed284beec
16 changed files with 42 additions and 40 deletions

View file

@ -25,7 +25,7 @@ use WebGUI::DateTime;
use DateTime::TimeZone;
use LWP::UserAgent;
use JSON qw(to_json from_json);
use JSON qw(encode_json decode_json);
=head1 NAME
@ -92,8 +92,8 @@ sub execute {
my $eventList = [];
my $feedList;
if ($instance->getScratch('events')) {
$eventList = from_json($instance->getScratch('events'));
$feedList = from_json($instance->getScratch('feeds'));
$eventList = decode_json($instance->getScratch('events'));
$feedList = decode_json($instance->getScratch('feeds'));
}
else {
my $ua = LWP::UserAgent->new(agent => "WebGUI");
@ -356,8 +356,8 @@ sub execute {
}
while (@$eventList) {
if ($startTime + 55 < time()) {
$instance->setScratch('events', to_json($eventList));
$instance->setScratch('feeds', to_json($feedList));
$instance->setScratch('events', encode_json($eventList));
$instance->setScratch('feeds', encode_json($feedList));
return $self->WAITING;
}
my $eventData = shift @$eventList;

View file

@ -96,7 +96,7 @@ sub execute {
# if there are urls left, we need to process again
if (scalar(@syndicatedUrls) > 0) {
$instance->setScratch("syndicatedUrls", JSON::to_json(\@syndicatedUrls));
$instance->setScratch("syndicatedUrls", JSON::encode_json(\@syndicatedUrls));
return $self->WAITING;
}
$instance->deleteScratch("syndicatedUrls");
@ -120,7 +120,7 @@ sub getSyndicatedUrls {
my $instance = shift;
my $syndicatedUrls = $instance->getScratch("syndicatedUrls");
if ($syndicatedUrls) {
return JSON::from_json($syndicatedUrls);
return JSON::decode_json($syndicatedUrls);
}
my $urls = [];
@ -131,7 +131,7 @@ sub getSyndicatedUrls {
foreach my $asset (@$assets) {
push @$urls, split(/\s+/, $asset->getRssUrl);
}
$instance->setScratch("syndicatedUrls", JSON::to_json($urls));
$instance->setScratch("syndicatedUrls", JSON::encode_json($urls));
return $urls;
}