]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Using JSON prop. content within response return.
authorMetabox <redacted>
Mon, 5 Aug 2019 01:40:00 +0000 (11:40 +1000)
committerMetabox <redacted>
Mon, 5 Aug 2019 01:40:00 +0000 (11:40 +1000)
htdocs/cgi-bin/json.cgi

index 64c546a10c0e7b2f33f7a3723b72377e2378c7d6..72df8c8b1c517329bca779b6685e6038242eb340 100755 (executable)
@@ -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     
    });   
 }