From: Dmitry Volyntsev Date: Fri, 20 Apr 2018 13:42:08 +0000 (+0300) Subject: Fixed JSON.stringify() for arrays with empty cells. X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=19b8a5cb887039f31d3531208834548970de668f;p=njs.git Fixed JSON.stringify() for arrays with empty cells. --- diff --git a/njs/njs_json.c b/njs/njs_json.c index 9ad86d0c..c7b952f9 100644 --- a/njs/njs_json.c +++ b/njs/njs_json.c @@ -1719,6 +1719,7 @@ njs_json_append_value(njs_json_stringify_t *stringify, njs_value_t *value) case NJS_VOID: case NJS_NULL: + case NJS_INVALID: case NJS_FUNCTION: return njs_json_buf_append(stringify, "null", 4); diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 693dd856..7fbee6a0 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -8673,6 +8673,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("JSON.stringify([])"), nxt_string("[]") }, + { nxt_string("var a = [1]; a[2] = 'x'; JSON.stringify(a)"), + nxt_string("[1,null,\"x\"]") }, + { nxt_string("JSON.stringify({a:\"b\",c:19,e:null,t:true,f:false})"), nxt_string("{\"a\":\"b\",\"c\":19,\"e\":null,\"t\":true,\"f\":false}") },