json: rename json-allow-nans? to json-allow-fp-special?.
parent
7379741b54
commit
08ec579f87
|
@ -14,11 +14,11 @@ HELP: json-print
|
||||||
$nl
|
$nl
|
||||||
"Some options can control the formatting of the result:"
|
"Some options can control the formatting of the result:"
|
||||||
{ $table
|
{ $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-friendly-keys? } "Convert - to _ in tuple slots and hashtable keys" }
|
||||||
{ { $link json-coerce-keys? } "Coerce hashtable keys into strings" }
|
{ { $link json-coerce-keys? } "Coerce hashtable keys into strings" }
|
||||||
{ { $link json-escape-slashes? } "Escape forward slashes inside strings" }
|
{ { $link json-escape-slashes? } "Escape forward slashes inside strings" }
|
||||||
{ { $link json-escape-unicode? } "Escape unicode values inside strings" }
|
{ { $link json-escape-unicode? } "Escape unicode values inside strings" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ $see-also >json } ;
|
{ $see-also >json } ;
|
||||||
|
|
|
@ -53,13 +53,13 @@ TUPLE: person first-name age ;
|
||||||
[ H{ { json-null 1 } } >json ] unit-test
|
[ H{ { json-null 1 } } >json ] unit-test
|
||||||
|
|
||||||
{ """{"Infinity":1}""" }
|
{ """{"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}""" }
|
{ """{"-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}""" }
|
{ """{"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\""
|
"\"\\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\""
|
||||||
|
|
|
@ -5,8 +5,8 @@ io.streams.string json kernel locals math math.parser mirrors
|
||||||
namespaces sequences strings tr words ;
|
namespaces sequences strings tr words ;
|
||||||
IN: json.writer
|
IN: json.writer
|
||||||
|
|
||||||
SYMBOL: json-allow-nans?
|
SYMBOL: json-allow-fp-special?
|
||||||
f json-allow-nans? set-global
|
f json-allow-fp-special? set-global
|
||||||
|
|
||||||
SYMBOL: json-friendly-keys?
|
SYMBOL: json-friendly-keys?
|
||||||
t json-friendly-keys? set-global
|
t json-friendly-keys? set-global
|
||||||
|
@ -79,7 +79,7 @@ M: integer stream-json-print
|
||||||
|
|
||||||
: float>json ( float -- string )
|
: float>json ( float -- string )
|
||||||
dup fp-special? [
|
dup fp-special? [
|
||||||
json-allow-nans? get [ json-error ] unless
|
json-allow-fp-special? get [ json-error ] unless
|
||||||
{
|
{
|
||||||
{ [ dup fp-nan? ] [ drop "NaN" ] }
|
{ [ dup fp-nan? ] [ drop "NaN" ] }
|
||||||
{ [ dup 1/0. = ] [ drop "Infinity" ] }
|
{ [ dup 1/0. = ] [ drop "Infinity" ] }
|
||||||
|
|
Loading…
Reference in New Issue