diff options
author | Christian A. Weber | 2019-05-13 17:15:46 +0200 |
---|---|---|
committer | Christian A. Weber | 2019-05-13 17:15:46 +0200 |
commit | 050af2a7605376cdfd7f513e09929299eab7a69c (patch) | |
tree | 3f807bac64a2817e5c9cfa6db665edf955e42c19 /itjs.class | |
parent | 89b34c8bdaf06b10268cab19796cd94684442124 (diff) | |
download | itools-050af2a7605376cdfd7f513e09929299eab7a69c.tar.gz itools-050af2a7605376cdfd7f513e09929299eab7a69c.tar.bz2 itools-050af2a7605376cdfd7f513e09929299eab7a69c.zip |
itjs::serialize() preserves data types (string, int, bool, null)
Diffstat (limited to 'itjs.class')
-rw-r--r-- | itjs.class | 23 |
1 files changed, 3 insertions, 20 deletions
@@ -39,30 +39,13 @@ function send_headers($charset = null) } /** - * Serialize the result into a javascript script + * json_encode the result with options suitable for using as javascript source code * @param $values Array with values to be serialized - * @param $envelope Encapsulate the data when callback function is provided (iframe solution) * @return String with javascript code to be sent to client */ -static function serialize($values, $envelope = false) +static function serialize($values) { - if (($envelope || isset($values['eof'])) && ($callback = it::replace(array('[^\w.]' => ""), $_REQUEST['itjs_call']))) - { - $target = $_REQUEST['itjs_iframe'] ? "parent" : "window"; - list($itclass) = explode('.', $callback); - $header = "$target.$itclass && $target.$callback && $target.$callback.dataReady("; - $footer = "," . intval($_REQUEST['itjs_callid']) . ");"; - - if ($_REQUEST['itjs_iframe']) # iframe-based loading required by Opera 7 - { - $header = '<script type="text/javascript">' . $header; - $footer .= "</script>"; - } - } - - $result = $header . itjs::encode($values) . $footer; - - return it_untaint($result); + return json_encode($values, JSON_UNESCAPED_UNICODE | (it::is_devel() ? JSON_PRETTY_PRINT : 0)); } /* |