json: rename json-allow-nans? to json-allow-fp-special?.

db4
John Benediktsson 2014-11-28 16:36:07 -08:00
parent 7379741b54
commit 08ec579f87
3 changed files with 11 additions and 11 deletions

View File

@ -14,7 +14,7 @@ HELP: json-print
$nl
"Some options can control the formatting of the result:"
{ $table
{ { $link json-allow-nans? } "Allow special floating-points: NaN, Infinity, -Infinity." }
{ { $link json-allow-fp-special? } "Allow special floating-points: NaN, Infinity, -Infinity" }
{ { $link json-friendly-keys? } "Convert - to _ in tuple slots and hashtable keys" }
{ { $link json-coerce-keys? } "Coerce hashtable keys into strings" }
{ { $link json-escape-slashes? } "Escape forward slashes inside strings" }

View File

@ -53,13 +53,13 @@ TUPLE: person first-name age ;
[ H{ { json-null 1 } } >json ] unit-test
{ """{"Infinity":1}""" }
[ t json-allow-nans? [ H{ { 1/0. 1 } } >json ] with-variable ] unit-test
[ t json-allow-fp-special? [ H{ { 1/0. 1 } } >json ] with-variable ] unit-test
{ """{"-Infinity":1}""" }
[ t json-allow-nans? [ H{ { -1/0. 1 } } >json ] with-variable ] unit-test
[ t json-allow-fp-special? [ H{ { -1/0. 1 } } >json ] with-variable ] unit-test
{ """{"NaN":1}""" }
[ t json-allow-nans? [ H{ { NAN: 333 1 } } >json ] with-variable ] unit-test
[ t json-allow-fp-special? [ H{ { NAN: 333 1 } } >json ] with-variable ] unit-test
{
"\"\\u0000\\u0001\\u0002\\u0003\\u0004\\u0005\\u0006\\u0007\\b\\t\\n\\u000b\\f\\r\\u000e\\u000f\\u0010\\u0011\\u0012\\u0013\\u0014\\u0015\\u0016\\u0017\\u0018\\u0019\\u001a\\u001b\\u001c\\u001d\\u001e\\u001f\""

View File

@ -5,8 +5,8 @@ io.streams.string json kernel locals math math.parser mirrors
namespaces sequences strings tr words ;
IN: json.writer
SYMBOL: json-allow-nans?
f json-allow-nans? set-global
SYMBOL: json-allow-fp-special?
f json-allow-fp-special? set-global
SYMBOL: json-friendly-keys?
t json-friendly-keys? set-global
@ -79,7 +79,7 @@ M: integer stream-json-print
: float>json ( float -- string )
dup fp-special? [
json-allow-nans? get [ json-error ] unless
json-allow-fp-special? get [ json-error ] unless
{
{ [ dup fp-nan? ] [ drop "NaN" ] }
{ [ dup 1/0. = ] [ drop "Infinity" ] }