pub / rememori

Simple file-based bookmarking and notes application
git clone https://src.jayvii.de/pub/rememori.git
Home | Log | Files | Exports | Refs | README | RSS

commit a2cd9bde6f974bac3d36df6b19a97e0da6d44040
parent 5458fc8f7f90d2f751a458e22e54d232aac361a2
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Tue, 29 Oct 2024 18:03:37 +0100

fix: use json_encode for json output

Diffstat:
Mlib/api.php | 17++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/api.php b/lib/api.php @@ -42,10 +42,10 @@ function api_error( } else { /* Use JSON as fallback */ header('Content-Type: application/json'); - echo "{" . PHP_EOL . - "\"status\": \"error\"," . PHP_EOL . - "\"message\": \"" . $message . "\"" . PHP_EOL . - "}" . PHP_EOL; + echo json_encode(array( + "status" => "error", + "message" => $message + )); } // if-statement } // function @@ -91,11 +91,10 @@ function api_write_success( } else { /* Use JSON as fallback */ header('Content-Type: application/json'); - echo "{" . PHP_EOL . - "\"status\": \"success\"," . PHP_EOL . - "\"message\": \"" . $GLOBALS["i18n_note_written_to"] . " " . $path . - "\"" . PHP_EOL . - "}" . PHP_EOL; + echo json_encode(array( + "status" => "success", + "message" => $GLOBALS["i18n_note_written_to"] . " " . $path + )); } // if-state }