From: Andrei Zmievski Date: Mon, 16 Oct 2006 17:04:51 +0000 (+0000) Subject: Patch to support primitive types. (Ilia) X-Git-Tag: RELEASE_1_0_0RC1~1277 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=867d4a97d11f31a7670ae417687f0f0ffed225a8;p=php Patch to support primitive types. (Ilia) --- diff --git a/ext/json/json.c b/ext/json/json.c index cbd5d3deb6..b92e36bda7 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -446,10 +446,35 @@ PHP_FUNCTION(json_decode) } else { + double d; + int type; + long p; + zval_dtor(z); FREE_ZVAL(z); efree(utf16); - RETURN_NULL(); + + if (parameter_len == 4) { + if (!strcasecmp(parameter, "null")) { + RETURN_NULL(); + } else if (!strcasecmp(parameter, "true")) { + RETURN_BOOL(1); + } + } else if (parameter_len == 5 && !strcasecmp(parameter, "false")) { + RETURN_BOOL(0); + } + if ((type = is_numeric_string(parameter, parameter_len, &p, &d, 0)) != 0) { + if (type == IS_LONG) { + RETURN_LONG(p); + } else if (type == IS_DOUBLE) { + RETURN_DOUBLE(d); + } + } + if (*parameter == '"' || parameter[parameter_len] == '"') { + RETURN_STRINGL(parameter+1, parameter_len-2, 1); + } else { + RETURN_STRINGL(parameter, parameter_len, 1); + } } }