Changed json-null to a SINGLETON for method dispatch
parent
260862603c
commit
986ea40835
|
@ -7,7 +7,7 @@ IN: json.reader
|
|||
|
||||
! Grammar for JSON from RFC 4627
|
||||
|
||||
SYMBOL: json-null
|
||||
SINGLETON: json-null
|
||||
|
||||
: [<&>] ( quot -- quot )
|
||||
{ } make unclip [ <&> ] reduce ;
|
||||
|
|
|
@ -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 ;
|
||||
|
|
Loading…
Reference in New Issue