From e79f02d161fd939774e4ae5f681393b291f10535 Mon Sep 17 00:00:00 2001 From: Raghu R Date: Sat, 28 Oct 2023 22:44:20 +0800 Subject: [PATCH] json: add special case and test for "-0" case --- basis/json/json-tests.factor | 1 + basis/json/json.factor | 1 + 2 files changed, 2 insertions(+) diff --git a/basis/json/json-tests.factor b/basis/json/json-tests.factor index 0f8225d109..469fe34aca 100644 --- a/basis/json/json-tests.factor +++ b/basis/json/json-tests.factor @@ -33,6 +33,7 @@ IN: json.tests ! not widely supported by javascript, but allowed in the grammar, and a nice ! feature to get { -0.0 } [ "-0.0" json> ] unit-test +{ -0.0 } [ "-0" json> ] unit-test { " fuzzy pickles " } [ " \" fuzzy pickles \" " json> ] unit-test { "while 1:\n\tpass" } [ " \"while 1:\n\tpass\" " json> ] unit-test diff --git a/basis/json/json.factor b/basis/json/json.factor index 021bfeb1f9..2d70e2a6c9 100644 --- a/basis/json/json.factor +++ b/basis/json/json.factor @@ -42,6 +42,7 @@ SYMBOL: json-depth { "Infinity" [ 1/0. ] } { "-Infinity" [ -1/0. ] } { "NaN" [ 0/0. ] } + { "-0" [ -0.0 ] } [ [ string>number ] [ not-a-json-number ] ?unless ] } case ] dip ; -- 2.34.1