summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorUrban Müller2025-04-10 14:21:36 +0200
committerUrban Müller2025-04-10 14:21:36 +0200
commitff13a5ee14cdb31307ecb16ddf2ab9f89d5d61ea (patch)
tree25c9647dd578b7befea08143be0bfdeb5645e904 /it.class
parente8b681292ae469a64df6033965babbe63be0290b (diff)
downloaditools-ff13a5ee14cdb31307ecb16ddf2ab9f89d5d61ea.tar.gz
itools-ff13a5ee14cdb31307ecb16ddf2ab9f89d5d61ea.tar.bz2
itools-ff13a5ee14cdb31307ecb16ddf2ab9f89d5d61ea.zip
json_decode: return json error in title
Diffstat (limited to 'it.class')
-rw-r--r--it.class4
1 files changed, 2 insertions, 2 deletions
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;
}
/**