json.writer: handle special floats.

db4
John Benediktsson 2014-11-14 17:56:19 -08:00
parent c3dd749f3d
commit dcbe85fe9c
1 changed files with 10 additions and 0 deletions

View File

@ -37,6 +37,16 @@ M: string stream-json-print
M: integer stream-json-print
[ number>string ] [ stream-write ] bi* ;
M: float stream-json-print
[
{
{ [ dup fp-nan? ] [ drop "NaN" ] }
{ [ dup 1/0. = ] [ drop "Infinity" ] }
{ [ dup -1/0. = ] [ drop "-Infinity" ] }
[ number>string ]
} cond
] dip stream-write ;
M: real stream-json-print
[ >float number>string ] [ stream-write ] bi* ;