-USING: kernel vocabs ;
+USING: kernel vocabs summary debugger io ;
IN: json
SINGLETON: json-null
ERROR: json-error ;
+ERROR: json-fp-special-error value ;
+M: json-fp-special-error summary drop "JSON serialization: illegal float:" ;
+
: if-json-null ( x if-null else -- )
[ dup json-null? ]
[ [ drop ] prepose ]
! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
-USING: help.markup help.syntax kernel ;
+USING: json help.markup help.syntax kernel ;
IN: json.writer
HELP: >json
}
{ $see-also >json } ;
+{ json-fp-special-error json-allow-fp-special? } related-words
+
+HELP: json-fp-special-error
+{ $error-description "Thrown by " { $link "json.writer" } " when attempting to serialize -1/0. or +1/0. or NaN when " { $link json-allow-fp-special? } " is not enabled." } ;
+
ARTICLE: "json.writer" "JSON writer"
"The " { $vocab-link "json.writer" } " vocabulary defines words for converting objects to JSON format."
{ $subsections
: float>json ( float -- string )
dup fp-special? [
- json-allow-fp-special? get [ json-error ] unless
+ json-allow-fp-special? get [ json-fp-special-error ] unless
{
{ [ dup fp-nan? ] [ drop "NaN" ] }
{ [ dup 1/0. = ] [ drop "Infinity" ] }