From a7917117faa5b99c0f84686630ba01d207901ed3 Mon Sep 17 00:00:00 2001 From: Metabox Date: Mon, 5 Aug 2019 11:40:00 +1000 Subject: [PATCH] Using JSON prop. content within response return. --- htdocs/cgi-bin/json.cgi | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/cgi-bin/json.cgi b/htdocs/cgi-bin/json.cgi index 64c546a..72df8c8 100755 --- a/htdocs/cgi-bin/json.cgi +++ b/htdocs/cgi-bin/json.cgi @@ -90,13 +90,8 @@ my $strp = DateTime::Format::Strptime->new( ############### &processSubmit; ############### -if($action eq 'load' && !$error){ - $json = $response; -} -else{ - &defaultJSON; -} +&defaultJSON; print $cgi->header( -expires => "+0s", -charset => "UTF-8" ); print $json; @@ -106,15 +101,20 @@ undef($session); exit; -sub defaultJSON{ +sub defaultJSON(){ + + my $content = $response; + if($action eq 'load' && !$error){ + $content = JSON->new->utf8->allow_nonref->decode($response); + $response = "Loaded Document!"; + } $json = JSON->new->utf8->space_after->pretty->allow_blessed->encode ({date => $strp->format_datetime($today), - response_origin => "LifeLog.".$RELEASE_VER, - response => $response, - alias => $userid, - log_id => $lid, - database=>$database, action => $action, error=>$error - #received => $doc + response_origin => "LifeLog.".$RELEASE_VER, + alias => $userid, log_id => $lid, database=>$database, action => $action, error=>$error, + response=>$response, + content=>$content, + #received => $doc }); } -- 2.34.1