$elt) { $ret .= $sep . '"' . $key . '":' . crayons_var2js($elt); $sep = ','; } return $ret .'}'; } else { $ret = '['; foreach ($var as $elt) { $ret .= $sep . crayons_var2js($elt); $sep = ','; } return $ret .']'; } } return false; } /** * Un json_encode qui marche en iso (la spec JSON exige utf-8) * @param $v * @return bool|false|mixed|string */ function crayons_json_encode($v) { if ($GLOBALS['meta']['charset'] == 'utf-8' and function_exists('json_encode')) { return json_encode($v); } $v = crayons_var2js($v); if ($GLOBALS['meta']['charset'] != 'utf-8') { include_spip('inc/charsets'); $v = charset2unicode($v); } return $v; } /** * https://code.spip.net/@json_export * * @param $var * @return bool|false|mixed|string * @deprecated */ function crayons_json_export($var) { return crayons_json_encode($var); }