json: rename to json-coerce.

db4
John Benediktsson 2014-11-28 08:51:16 -08:00
parent 9bba5d1312
commit a363c2faf4
1 changed files with 9 additions and 8 deletions

View File

@ -105,13 +105,14 @@ M: sequence stream-json-print
TR: json-friendly "-" "_" ; TR: json-friendly "-" "_" ;
GENERIC: json-key ( obj -- str ) GENERIC: json-coerce ( obj -- str )
M: f json-key drop "false" ; M: f json-coerce drop "false" ;
M: t json-key drop "true" ; M: t json-coerce drop "true" ;
M: json-null json-key drop "null" ; M: json-null json-coerce drop "null" ;
M: integer json-key number>string ; M: string json-coerce ;
M: float json-key float>json ; M: integer json-coerce number>string ;
M: real json-key >float number>string ; M: float json-coerce float>json ;
M: real json-coerce >float number>string ;
:: json-print-assoc ( obj stream -- ) :: json-print-assoc ( obj stream -- )
CHAR: { stream stream-write1 obj >alist CHAR: { stream stream-write1 obj >alist
@ -121,7 +122,7 @@ M: real json-key >float number>string ;
first2 [ first2 [
dup string? dup string?
[ _ [ json-friendly ] when ] [ _ [ json-friendly ] when ]
[ _ [ json-key ] when ] if [ _ [ json-coerce ] when ] if
stream stream-json-print stream stream-json-print
] [ ] [
CHAR: : stream stream-write1 CHAR: : stream stream-write1