From kengruven at gmail.com Fri Dec 29 01:00:20 2006 From: kengruven at gmail.com (Ken Harris) Date: Thu, 28 Dec 2006 17:00:20 -0800 Subject: [cl-json-devel] Characters Message-ID: Hello! One thing I discovered when I tried to encode a big s-exp with encode-json-to-string is that it doesn't support characters. This kind of makes sense, since JSON itself doesn't have a separate "character" type, and some of the big usrs of JSON (ECMAscript and Python) don't, either. A JSON decoder couldn't tell what's a length-1 string, and what's a character. OTOH, for my program, it would be really handy to *encode* characters directly. I decided to try writing a patch, after about 5 seconds came up with this: (defmethod encode-json ((c character) stream) (encode-json (string c) stream)) Since this is Lisp, it's both insanely easy, and it doesn't have to be part of cl-json for me to use it as if it was. :-) I guess it doesn't really benefit me for this to be part of cl-json, but if that's of any use to you, feel free to use/add it. cheers, - Ken From henrik at evahjelte.com Fri Dec 29 10:44:22 2006 From: henrik at evahjelte.com (Henrik Hjelte) Date: Fri, 29 Dec 2006 11:44:22 +0100 Subject: [cl-json-devel] Characters In-Reply-To: References: Message-ID: <1167389062.5651.38.camel@trinidad> It seems lika a good idea, so I have applied your patch to the darcs repository. Thanks, Henrik On Thu, 2006-12-28 at 17:00 -0800, Ken Harris wrote: > Hello! > > One thing I discovered when I tried to encode a big s-exp with > encode-json-to-string is that it doesn't support characters. > > This kind of makes sense, since JSON itself doesn't have a separate > "character" type, and some of the big usrs of JSON (ECMAscript and > Python) don't, either. A JSON decoder couldn't tell what's a length-1 > string, and what's a character. > > OTOH, for my program, it would be really handy to *encode* characters directly. > > I decided to try writing a patch, after about 5 seconds came up with this: > > (defmethod encode-json ((c character) stream) > (encode-json (string c) stream)) > > Since this is Lisp, it's both insanely easy, and it doesn't have to be > part of cl-json for me to use it as if it was. :-) > > I guess it doesn't really benefit me for this to be part of cl-json, > but if that's of any use to you, feel free to use/add it. > > > cheers, > > > - Ken > _______________________________________________ > cl-json-devel mailing list > cl-json-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-json-devel > >