From 2a2ba78a71918f86e94c3a21fc52e8cdfdb52b68 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 18 Jan 2019 15:10:58 +0100 Subject: allow returning assoc arrays --- it.class | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/it.class b/it.class index 89d799a..8209e65 100644 --- a/it.class +++ b/it.class @@ -1138,10 +1138,11 @@ static function json_encode($data) /** * Decodes json data and provides warning if failed + * $p['assoc'] Return objects as assoc arrays */ static function json_decode($json, $p = []) { - return ($data = json_decode($json)) === null && $json != 'null' ? it::error((array)$p['it_error'] + ['title' => "invalid json", 'body' => $json]) : $data; + return ($data = json_decode($json, $p['assoc'])) === null && $json != 'null' ? it::error((array)$p['it_error'] + ['title' => "invalid json", 'body' => $json]) : $data; } /** -- cgit v1.2.3