Changed json-null to a SINGLETON for method dispatch

db4
Peter Burns 2008-11-06 04:38:12 -08:00
parent 260862603c
commit 986ea40835
2 changed files with 6 additions and 3 deletions

View File

@ -7,7 +7,7 @@ IN: json.reader
! Grammar for JSON from RFC 4627
SYMBOL: json-null
SINGLETON: json-null
: [<&>] ( quot -- quot )
{ } make unclip [ <&> ] reduce ;

View File

@ -16,7 +16,10 @@ M: f json-print ( f -- )
drop "false" write ;
M: t json-print ( t -- )
drop "true" write
drop "true" write ;
M: json-null json-print ( null -- )
drop "null" write ;
M: string json-print ( obj -- )
CHAR: " write1 "\"" split "\\\"" join CHAR: \r swap remove "\n" split "\\r\\n" join write CHAR: " write1 ;
@ -44,4 +47,4 @@ M: hashtable json-print ( hashtable -- )
CHAR: } write1 ;
M: object json-print ( object -- )
dup json-null = [ "null" write drop ] [ unparse json-print ] if ;
unparse json-print ;