* @param array $payload */
(int $status, array $payload)
| 23 | * @param array<string,mixed> $payload |
| 24 | */ |
| 25 | function fr_pro_json(int $status, array $payload): void |
| 26 | { |
| 27 | fr_pro_bootstrap(); |
| 28 | |
| 29 | http_response_code($status); |
| 30 | header('Content-Type: application/json; charset=utf-8'); |
| 31 | $json = json_encode($payload, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
| 32 | if (!is_string($json) || $json === '') { |
| 33 | http_response_code(500); |
| 34 | $json = '{"ok":false,"error":"JSON encode failed"}'; |
| 35 | } |
| 36 | echo $json; |
| 37 | exit; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | if (!function_exists('fr_pro_read_json')) { |
no test coverage detected