use proper JSON encoding/decoding
This commit is contained in:
parent
7023683b48
commit
bf9bd2f0d2
18 changed files with 54 additions and 54 deletions
|
|
@ -902,7 +902,7 @@ sub www_getAttributes {
|
|||
my $jsonOutput;
|
||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||
|
||||
return JSON->new->utf8->encode($jsonOutput);
|
||||
return JSON->new->encode($jsonOutput);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -561,7 +561,7 @@ sub getRichEditor {
|
|||
while (my ($plugin, $path) = each %loadPlugins) {
|
||||
$out .= "tinymce.PluginManager.load('$plugin', '$path');\n";
|
||||
}
|
||||
$out .= "\ttinyMCE.init(" . JSON->new->utf8->pretty->encode(\%config) . " )\n"
|
||||
$out .= "\ttinyMCE.init(" . JSON->new->pretty->encode(\%config) . " )\n"
|
||||
. "</script>";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ sub view {
|
|||
. WebGUI::Form::hidden($session,
|
||||
{
|
||||
name => "callback",
|
||||
value => JSON->new->utf8->encode({ url => $self->getUrl})
|
||||
value => JSON->new->encode({ url => $self->getUrl})
|
||||
})
|
||||
. WebGUI::Form::submit($session, {value => $i18n->get("populate from address book")})
|
||||
. WebGUI::Form::formFooter($session)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package WebGUI::Asset::Sku::EMSTicket;
|
|||
use strict;
|
||||
use base 'WebGUI::Asset::Sku';
|
||||
use Tie::IxHash;
|
||||
use JSON;
|
||||
use JSON ();
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -293,7 +293,7 @@ If specified, returns a single value for the key specified.
|
|||
sub getEventMetaData {
|
||||
my $self = shift;
|
||||
my $key = shift;
|
||||
my $metadata = JSON->new->utf8->decode($self->get("eventMetaData") || '{}');
|
||||
my $metadata = JSON->new->decode($self->get("eventMetaData") || '{}');
|
||||
if (defined $key) {
|
||||
return $metadata->{$key};
|
||||
}
|
||||
|
|
@ -438,7 +438,7 @@ sub processPropertiesFromFormPost {
|
|||
my $date = WebGUI::DateTime->new($self->session, time())->toDatabase;
|
||||
my $startDate = $form->process('startDate', "dateTime", $date,
|
||||
{ defaultValue => $date, timeZone => $self->getParent->get("timezone")});
|
||||
$self->update({eventMetaData => JSON->new->utf8->encode(\%metadata), startDate => $startDate});
|
||||
$self->update({eventMetaData => JSON->new->encode(\%metadata), startDate => $startDate});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -470,7 +470,7 @@ A hash reference containing all the metadata properties to set.
|
|||
sub setEventMetaData {
|
||||
my $self = shift;
|
||||
my $properties = shift;
|
||||
$self->update({eventMetaData => JSON->new->utf8->encode($properties)});
|
||||
$self->update({eventMetaData => JSON->new->encode($properties)});
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ sub www_editBadgeGroup {
|
|||
my ($form, $db) = $self->session->quick(qw(form db));
|
||||
my $f = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
|
||||
my $badgeGroup = $db->getRow("EMSBadgeGroup","badgeGroupId",$form->get('badgeGroupId'));
|
||||
$badgeGroup->{badgeList} = ($badgeGroup->{badgeList} ne "") ? JSON::decode_json($badgeGroup->{badgeList}) : [];
|
||||
$badgeGroup->{badgeList} = ($badgeGroup->{badgeList} ne "") ? JSON::from_json($badgeGroup->{badgeList}) : [];
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_EventManagementSystem");
|
||||
$f->hidden(name=>'func', value=>'editBadgeGroupSave');
|
||||
$f->hidden(name=>'badgeGroupId', value=>$form->get('badgeGroupId'));
|
||||
|
|
@ -842,7 +842,7 @@ sub www_getBadgesAsJson {
|
|||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->utf8->encode(\%results);
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -974,7 +974,7 @@ sub www_getRegistrantAsJson {
|
|||
$badgeInfo->{ribbons} = \@ribbons;
|
||||
|
||||
# build json datasource
|
||||
return JSON->new->utf8->encode($badgeInfo);
|
||||
return JSON->new->encode($badgeInfo);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -1038,7 +1038,7 @@ sub www_getRegistrantsAsJson {
|
|||
|
||||
# build json datasource
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->utf8->encode(\%results);
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1073,7 +1073,7 @@ sub www_getRibbonsAsJson {
|
|||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->utf8->encode(\%results);
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1184,7 +1184,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate
|
|||
my $description = $ticket->get('description');
|
||||
my $data = $ticket->get('eventMetaData');
|
||||
$data = '{}' if ($data eq "");
|
||||
my $meta = JSON->new->utf8->decode($data);
|
||||
my $meta = JSON->new->decode($data);
|
||||
foreach my $field (@{$self->getEventMetaFields}) {
|
||||
my $label = $field->{label};
|
||||
if ($field->{visible} && $meta->{$label} ne "") {
|
||||
|
|
@ -1228,7 +1228,7 @@ className='WebGUI::Asset::Sku::EMSTicket' and state='published' and revisionDate
|
|||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->utf8->encode(\%results);
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1263,7 +1263,7 @@ sub www_getTokensAsJson {
|
|||
$results{'sort'} = undef;
|
||||
$results{'dir'} = "asc";
|
||||
$session->http->setMimeType('application/json');
|
||||
return JSON->new->utf8->encode(\%results);
|
||||
return JSON->new->encode(\%results);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -987,7 +987,7 @@ assetData.revisionDate
|
|||
my $jsonOutput;
|
||||
$jsonOutput->{ResultSet} = {Result=>\@results};
|
||||
|
||||
my $encodedOutput = JSON->new->utf8->encode($jsonOutput);
|
||||
my $encodedOutput = JSON->new->encode($jsonOutput);
|
||||
return $encodedOutput;
|
||||
}
|
||||
|
||||
|
|
@ -1090,7 +1090,7 @@ sub www_getCompareListData {
|
|||
|
||||
$session->http->setMimeType("application/json");
|
||||
|
||||
return JSON->new->utf8->encode($jsonOutput);
|
||||
return JSON->new->encode($jsonOutput);
|
||||
}
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1517,7 +1517,7 @@ sub www_deleteThingDataViaAjax {
|
|||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
my $thingProperties = $self->getThing($thingId);
|
||||
|
|
@ -1528,11 +1528,11 @@ sub www_deleteThingDataViaAjax {
|
|||
$self->deleteThingData($thingId,$thingDataId);
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
return JSON->new->utf8->encode({message => "Data with thingDataId $thingDataId was deleted."});
|
||||
return JSON->new->encode({message => "Data with thingDataId $thingDataId was deleted."});
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingId you specified can not be found."});
|
||||
return JSON->new->encode({message => "The thingId you specified can not be found."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2455,7 +2455,7 @@ sub www_editThingDataSaveViaAjax {
|
|||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
my $thingProperties = $self->getThing($thingId);
|
||||
|
|
@ -2467,19 +2467,19 @@ sub www_editThingDataSaveViaAjax {
|
|||
|
||||
if($thingDataId eq 'new' && $self->hasEnteredMaxPerUser($thingId)){
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => $i18n->get("has entered max per user message")});
|
||||
return JSON->new->encode({message => $i18n->get("has entered max per user message")});
|
||||
}
|
||||
|
||||
my ($newThingDataId,$errors) = $self->editThingDataSave($thingId,$thingDataId);
|
||||
|
||||
if ($errors){
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode($errors);
|
||||
return JSON->new->encode($errors);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingId you requested can not be found."});
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2568,7 +2568,7 @@ sub www_getThingViaAjax {
|
|||
|
||||
unless ($thingId) {
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => "Can't return thing properties without a thingId."});
|
||||
return JSON->new->encode({message => "Can't return thing properties without a thingId."});
|
||||
}
|
||||
|
||||
my $thingProperties = $self->getThing($thingId);
|
||||
|
|
@ -2586,11 +2586,11 @@ sub www_getThingViaAjax {
|
|||
$thingProperties->{field_loop} = \@field_loop;
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
return JSON->new->utf8->encode($thingProperties);
|
||||
return JSON->new->encode($thingProperties);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingId you requested can not be found."});
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2620,11 +2620,11 @@ sub www_getThingsViaAjax {
|
|||
}
|
||||
}
|
||||
if (scalar @visibleThings > 0){
|
||||
return JSON->new->utf8->encode(\@visibleThings);
|
||||
return JSON->new->encode(\@visibleThings);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "No visible Things were found in this Thingy."});
|
||||
return JSON->new->encode({message => "No visible Things were found in this Thingy."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2982,7 +2982,7 @@ sub www_searchViaAjax {
|
|||
|
||||
unless ($thingId) {
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => "Can't perform search without a thingId."});
|
||||
return JSON->new->encode({message => "Can't perform search without a thingId."});
|
||||
}
|
||||
|
||||
if ($thingProperties->{thingId}){
|
||||
|
|
@ -2993,11 +2993,11 @@ sub www_searchViaAjax {
|
|||
my $var = $self->getSearchTemplateVars($thingId,$thingProperties);
|
||||
|
||||
$session->http->setMimeType("application/json");
|
||||
return JSON->new->utf8->encode($var);
|
||||
return JSON->new->encode($var);
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingId you requested can not be found."});
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3393,7 +3393,7 @@ sub www_viewThingDataViaAjax {
|
|||
|
||||
unless ($thingId && $thingDataId) {
|
||||
$session->http->setStatus("400", "Bad Request");
|
||||
return JSON->new->utf8->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
return JSON->new->encode({message => "Can't get thing data without a thingId and a thingDataId."});
|
||||
}
|
||||
|
||||
my $thingProperties = $self->getThing($thingId);
|
||||
|
|
@ -3404,16 +3404,16 @@ sub www_viewThingDataViaAjax {
|
|||
my $output = $self->getViewThingVars($thingId,$thingDataId);
|
||||
|
||||
if ($output){
|
||||
return JSON->new->utf8->encode($output);
|
||||
return JSON->new->encode($output);
|
||||
}
|
||||
else{
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingDataId you requested can not be found."});
|
||||
return JSON->new->encode({message => "The thingDataId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$session->http->setStatus("404", "Not Found");
|
||||
return JSON->new->utf8->encode({message => "The thingId you requested can not be found."});
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue