Skip to content
This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Commit 6d854bb

Browse files
committed
✨ add json method() for json output
Signed-off-by: otengkwame <[email protected]>
1 parent 1571c1e commit 6d854bb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

framework/core/Output.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,17 @@ public function cache($time)
390390

391391
// --------------------------------------------------------------------
392392

393+
public function json($data = null, $statusCode = 200)
394+
{
395+
echo $this->set_status_header($statusCode)
396+
->set_content_type('application/json', 'utf-8')
397+
->set_output(json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES))
398+
->_display();
399+
exit;
400+
}
401+
402+
// --------------------------------------------------------------------
403+
393404
/**
394405
* Display Output
395406
*

0 commit comments

Comments
 (0)