Welcome! Log In Create A New Profile

Advanced

[njs] Fixed JSON.stringify() for arrays with empty cells.

Dmitry Volyntsev
April 20, 2018 09:44AM
details: http://hg.nginx.org/njs/rev/cb7115e9fa1e
branches:
changeset: 499:cb7115e9fa1e
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Fri Apr 20 16:42:08 2018 +0300
description:
Fixed JSON.stringify() for arrays with empty cells.

diffstat:

njs/njs_json.c | 1 +
njs/test/njs_unit_test.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)

diffs (24 lines):

diff -r 35486fa8c8b5 -r cb7115e9fa1e njs/njs_json.c
--- a/njs/njs_json.c Wed Apr 11 17:31:53 2018 +0300
+++ b/njs/njs_json.c Fri Apr 20 16:42:08 2018 +0300
@@ -1719,6 +1719,7 @@ njs_json_append_value(njs_json_stringify

case NJS_VOID:
case NJS_NULL:
+ case NJS_INVALID:
case NJS_FUNCTION:
return njs_json_buf_append(stringify, "null", 4);

diff -r 35486fa8c8b5 -r cb7115e9fa1e njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Wed Apr 11 17:31:53 2018 +0300
+++ b/njs/test/njs_unit_test.c Fri Apr 20 16:42:08 2018 +0300
@@ -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}") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed JSON.stringify() for arrays with empty cells.

Dmitry Volyntsev 254 April 20, 2018 09:44AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 314
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready