From ff13a5ee14cdb31307ecb16ddf2ab9f89d5d61ea Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 10 Apr 2025 14:21:36 +0200 Subject: json_decode: return json error in title --- it.class | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 83e7d0e..cc53558 100644 --- a/it.class +++ b/it.class @@ -1260,12 +1260,12 @@ static function json_encode($data, $p = []) } /** - * Decodes json data and provides warning if failed + * Decodes json data and provides warning if failed. Objects returned as objects by default * $p['assoc'] Return objects as assoc arrays */ static function json_decode($json, $p = []) { - return ($data = json_decode($json, $p['assoc'])) === null && trim($json) != 'null' ? it::error((array)$p['it_error'] + ['title' => "invalid json", 'body' => $json]) : $data; + return ($data = json_decode($json, $p['assoc'])) === null && trim($json) != 'null' ? it::error((array)$p['it_error'] + ['title' => "invalid json: " . json_last_error(), 'body' => $json]) : $data; } /** -- cgit v1.2.3