From pbourguignon at ravenpack.com Fri Mar 9 14:35:11 2007 From: pbourguignon at ravenpack.com (Pascal Bourguignon) Date: Fri, 9 Mar 2007 15:35:11 +0100 Subject: [cl-json-devel] cl-json asdf packaging. Message-ID: <20070309143510.D245B43A2F@crow2.exxs.net> There's a problem with the packaging of cl-json. ======================================================================== CL-USER(1): (asdf-install:install :cl-json) ;;; Installing acldns patch, version 1 ;;; ASDF-INSTALL: Downloading 9618 bytes from http://common-lisp.net/project/cl-json/cl-json_0.1.3.tar.gz to /usr/local/asdf-install/site/CL-JSON.asdf-install-tmp ... gpg: Signature made Wed Feb 22 23:15:11 2006 CET using DSA key ID 13DC794B gpg: Can't check signature: public key not found "[GNUPG:] ERRSIG DB0819FF13DC794B 17 2 00 1140646511 9" "[GNUPG:] NO_PUBKEY DB0819FF13DC794B" Error: No key found for key id 0xDB0819FF13DC794B. Try some command like gpg --recv-keys 0xDB0819FF13DC794B [condition type: KEY-NOT-FOUND] Restart actions (select using :continue): 0: Don't check GPG signature for this package 1: Return to Top Level (an "abort" restart). 2: Abort entirely from this (lisp) process. [1] CL-USER(2): :cont 0 ;;; ASDF-INSTALL: Installing /usr/local/asdf-install/site/CL-JSON.asdf-install-tmp in /usr/local/asdf-install/site/, /usr/local/asdf-install/site-systems/ cl-json_0.1.3/src/common.lisp cl-json_0.1.3/src/encoder.lisp cl-json_0.1.3/src/decoder.lisp cl-json_0.1.3/src/package.lisp cl-json_0.1.3/t/testjson.lisp cl-json_0.1.3/t/fail1.json cl-json_0.1.3/t/fail10.json cl-json_0.1.3/t/fail11.json cl-json_0.1.3/t/fail12.json cl-json_0.1.3/t/fail13.json cl-json_0.1.3/t/fail14.json cl-json_0.1.3/t/fail15.json cl-json_0.1.3/t/fail16.json cl-json_0.1.3/t/fail17.json cl-json_0.1.3/t/fail18.json cl-json_0.1.3/t/fail19.json cl-json_0.1.3/t/fail2.json cl-json_0.1.3/t/fail20.json cl-json_0.1.3/t/fail21.json cl-json_0.1.3/t/fail22.json cl-json_0.1.3/t/fail23.json cl-json_0.1.3/t/fail24.json cl-json_0.1.3/t/fail3.json cl-json_0.1.3/t/fail4.json cl-json_0.1.3/t/fail5.json cl-json_0.1.3/t/fail6.json cl-json_0.1.3/t/fail7.json cl-json_0.1.3/t/fail8.json cl-json_0.1.3/t/fail9.json cl-json_0.1.3/t/package.lisp cl-json_0.1.3/t/pass1.json cl-json_0.1.3/t/pass2.json cl-json_0.1.3/t/pass3.json cl-json_0.1.3/t/testencoder.lisp cl-json_0.1.3/t/testdecoder.lisp cl-json_0.1.3/doc/index.html cl-json_0.1.3/doc/style.css cl-json_0.1.3/json.asd #P"/usr/local/asdf-install/site/cl-json_0.1.3/" #P"/usr/local/asdf-install/site/cl-json_0.1.3/" Error: component "cl-json" not found [condition type: MISSING-COMPONENT] Restart actions (select using :continue): 0: Retry installation 1: Return to Top Level (an "abort" restart). 2: Abort entirely from this (lisp) process. [1] CL-USER(3): :cont 1 No man's ambition has a right to stand in the way of performing a simple act of justice. -- John Altgeld CL-USER(4): (asdf:oos 'asdf:load-op :cl-json) Error: component "cl-json" not found [condition type: MISSING-COMPONENT] Restart actions (select using :continue): 0: Return to Top Level (an "abort" restart). 1: Abort entirely from this (lisp) process. [1] CL-USER(5): :q CL-USER(6): ======================================================================== With the attached patch, we can install and load it smoothly. (Rename the system file cl-json.asd and rename the defsystem :cl-json to put some consistency in). ======================================================================== CL-USER(1): (asdf:oos 'asdf:load-op :cl-json) ; loading system definition from ; /usr/local/asdf-install/site-systems/cl-json.asd into ; # ; registering # as CL-JSON ; registering # as JSON.TEST NIL ======================================================================== -- Pascal Bourguignon http://www.ravenpack.com/ -------------- next part -------------- A non-text attachment was scrubbed... Name: cl-json-0.1.3.patch.gz Type: application/x-gzip Size: 1346 bytes Desc: patch URL: From henrik at evahjelte.com Fri Mar 9 14:59:01 2007 From: henrik at evahjelte.com (Henrik Hjelte) Date: Fri, 09 Mar 2007 15:59:01 +0100 Subject: [cl-json-devel] cl-json asdf packaging. In-Reply-To: <20070309143510.D245B43A2F@crow2.exxs.net> References: <20070309143510.D245B43A2F@crow2.exxs.net> Message-ID: <1173452341.7459.71.camel@trinidad> Thanks! I just have want to do one more change before I release a new asdf version, in the meanwhile I recommend the darcs repo, it contains new stuff like json-rpc and json-bind. /Henrik On Fri, 2007-03-09 at 15:35 +0100, Pascal Bourguignon wrote: > There's a problem with the packaging of cl-json. > > ======================================================================== > > CL-USER(1): (asdf-install:install :cl-json) > ;;; Installing acldns patch, version 1 > ;;; ASDF-INSTALL: Downloading 9618 bytes from http://common-lisp.net/project/cl-json/cl-json_0.1.3.tar.gz to /usr/local/asdf-install/site/CL-JSON.asdf-install-tmp ... > gpg: Signature made Wed Feb 22 23:15:11 2006 CET using DSA key ID 13DC794B > gpg: Can't check signature: public key not found > > > "[GNUPG:] ERRSIG DB0819FF13DC794B 17 2 00 1140646511 9" > "[GNUPG:] NO_PUBKEY DB0819FF13DC794B" > Error: No key found for key id 0xDB0819FF13DC794B. Try some command like > gpg --recv-keys 0xDB0819FF13DC794B > [condition type: KEY-NOT-FOUND] > > Restart actions (select using :continue): > 0: Don't check GPG signature for this package > 1: Return to Top Level (an "abort" restart). > 2: Abort entirely from this (lisp) process. > [1] CL-USER(2): :cont 0 > ;;; ASDF-INSTALL: Installing /usr/local/asdf-install/site/CL-JSON.asdf-install-tmp in /usr/local/asdf-install/site/, /usr/local/asdf-install/site-systems/ > cl-json_0.1.3/src/common.lisp > cl-json_0.1.3/src/encoder.lisp > cl-json_0.1.3/src/decoder.lisp > cl-json_0.1.3/src/package.lisp > cl-json_0.1.3/t/testjson.lisp > cl-json_0.1.3/t/fail1.json > cl-json_0.1.3/t/fail10.json > cl-json_0.1.3/t/fail11.json > cl-json_0.1.3/t/fail12.json > cl-json_0.1.3/t/fail13.json > cl-json_0.1.3/t/fail14.json > cl-json_0.1.3/t/fail15.json > cl-json_0.1.3/t/fail16.json > cl-json_0.1.3/t/fail17.json > cl-json_0.1.3/t/fail18.json > cl-json_0.1.3/t/fail19.json > cl-json_0.1.3/t/fail2.json > cl-json_0.1.3/t/fail20.json > cl-json_0.1.3/t/fail21.json > cl-json_0.1.3/t/fail22.json > cl-json_0.1.3/t/fail23.json > cl-json_0.1.3/t/fail24.json > cl-json_0.1.3/t/fail3.json > cl-json_0.1.3/t/fail4.json > cl-json_0.1.3/t/fail5.json > cl-json_0.1.3/t/fail6.json > cl-json_0.1.3/t/fail7.json > cl-json_0.1.3/t/fail8.json > cl-json_0.1.3/t/fail9.json > cl-json_0.1.3/t/package.lisp > cl-json_0.1.3/t/pass1.json > cl-json_0.1.3/t/pass2.json > cl-json_0.1.3/t/pass3.json > cl-json_0.1.3/t/testencoder.lisp > cl-json_0.1.3/t/testdecoder.lisp > cl-json_0.1.3/doc/index.html > cl-json_0.1.3/doc/style.css > cl-json_0.1.3/json.asd > > #P"/usr/local/asdf-install/site/cl-json_0.1.3/" > #P"/usr/local/asdf-install/site/cl-json_0.1.3/" > Error: component "cl-json" not found > [condition type: MISSING-COMPONENT] > > Restart actions (select using :continue): > 0: Retry installation > 1: Return to Top Level (an "abort" restart). > 2: Abort entirely from this (lisp) process. > [1] CL-USER(3): :cont 1 > No man's ambition has a right to stand in the way of performing a simple > act of justice. > -- John Altgeld > CL-USER(4): (asdf:oos 'asdf:load-op :cl-json) > Error: component "cl-json" not found > [condition type: MISSING-COMPONENT] > > Restart actions (select using :continue): > 0: Return to Top Level (an "abort" restart). > 1: Abort entirely from this (lisp) process. > [1] CL-USER(5): :q > CL-USER(6): > ======================================================================== > > > With the attached patch, we can install and load it smoothly. > (Rename the system file cl-json.asd and rename the defsystem :cl-json > to put some consistency in). > > ======================================================================== > CL-USER(1): (asdf:oos 'asdf:load-op :cl-json) > ; loading system definition from > ; /usr/local/asdf-install/site-systems/cl-json.asd into > ; # > ; registering # as CL-JSON > ; registering # as JSON.TEST > NIL > ======================================================================== > > > _______________________________________________ > cl-json-devel mailing list > cl-json-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-json-devel From utsl at quic.net Thu Mar 22 12:56:09 2007 From: utsl at quic.net (Nathan Hawkins) Date: Thu, 22 Mar 2007 08:56:09 -0400 Subject: [cl-json-devel] patch to improve encode-json for lists Message-ID: This fairly simple patch seems to enable encode-json to handle alists. After applying: ;; handles alists (defvar *foo* '((a . 1) (b . 2) (c . 3))) (encode-json-to-string *foo*) --> "{\"a\":1,\"b\":2,\"c\":3}" ;; normal lists still work (defvar *bar* '(1 2 3 4 5)) (encode-json-to-string *bar*) --> "[1,2,3,4,5]" ;; messed up lists of alists which contain lists also works now (defvar *baz* '(((a . 1) (b .2) (c . 3) (d . (1 2 3 4 5))))) (encode-json-to-string *baz*) --> "[{\"a\":1,\"b\":[0.2],\"c\":3,\"d\":[1,2,3,4,5]}]" ;; even better, decode-json likes the output (decode-json-from-string "[{\"a\":1,\"b\":[0.2 ],\"c\":3,\"d\":[1,2,3,4,5]}]") --> (((:A . 1) (:B 0.2) (:C . 3) (:D 1 2 3 4 5))) One thing you can't do is encode a list appended to an alist. That won't work, and I don't know how you'd encode it in JSON anyway. Someone who's had way more sleep than I have lately should test this as well. But I can now both encode and decode lists of alists, which scratches my particular itch... Nathan diff -rN -u old-cl-json/src/encoder.lisp new-cl-json/src/encoder.lisp --- old-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 -0400 +++ new-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 -0400 @@ -25,6 +25,12 @@ (t (write-json-string (funcall *symbol-to-string-fn* s) stream)))) (defmethod encode-json((s sequence ) stream) + (if (and (consp (car s)) + (atom (cdar s))) + (encode-json-alist s stream) + (encode-json-list s stream))) + +(defun encode-json-list (s stream) (let ((first-element t)) (write-char #\[ stream) (map nil #'(lambda (element) -------------- next part -------------- An HTML attachment was scrubbed... URL: From henrik at evahjelte.com Sat Mar 24 11:32:02 2007 From: henrik at evahjelte.com (Henrik Hjelte) Date: Sat, 24 Mar 2007 12:32:02 +0100 Subject: [cl-json-devel] patch to improve encode-json for lists In-Reply-To: References: Message-ID: <1174735922.5885.60.camel@trinidad> On Thu, 2007-03-22 at 08:56 -0400, Nathan Hawkins wrote: > This fairly simple patch seems to enable encode-json to handle alists. Thanks. I added your first example as a testcase, test-encode-json-nathan-hawkins (defvar *foo* '((a . 1) (b . 2) (c . 3))) (encode-json-to-string *foo*) --> "{\"a\":1,\"b\":2,\"c\":3}" When I added your patch several other tests broke. There is a problem with you code that you guess the type of of the list from the first element. So I instead made a solution that works with your code and doesn't break any tests. It is in darcs now. Also, I have added Pascal Bourguignons patch to darcs, so beware that json.asd is now renamed cl-json.asd. Thanks, Henrik > > ;; normal lists still work > (defvar *bar* '(1 2 3 4 5)) > (encode-json-to-string *bar*) > --> "[1,2,3,4,5]" > > ;; messed up lists of alists which contain lists also works now > (defvar *baz* '(((a . 1) (b .2) (c . 3) (d . (1 2 3 4 5))))) > (encode-json-to-string *baz*) > --> "[{\"a\":1,\"b\":[0.2],\"c\":3,\"d\":[1,2,3,4,5]}]" > > ;; even better, decode-json likes the output > (decode-json-from-string "[{\"a\":1,\"b\":[ 0.2],\"c\":3,\"d > \":[1,2,3,4,5]}]") > --> (((:A . 1) (:B 0.2) (:C . 3) (:D 1 2 3 4 5))) > > One thing you can't do is encode a list appended to an alist. That > won't work, and I don't know how you'd > encode it in JSON anyway. > > Someone who's had way more sleep than I have lately should test this > as well. But I can now both encode > and decode lists of alists, which scratches my particular itch... > > Nathan > > diff -rN -u old-cl-json/src/encoder.lisp new-cl-json/src/encoder.lisp > --- old-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 > -0400 > +++ new-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 > -0400 > @@ -25,6 +25,12 @@ > (t (write-json-string (funcall *symbol-to-string-fn* s) > stream)))) > > (defmethod encode-json((s sequence ) stream) > + (if (and (consp (car s)) > + (atom (cdar s))) > + (encode-json-alist s stream) > + (encode-json-list s stream))) > + > +(defun encode-json-list (s stream) > (let ((first-element t)) > (write-char #\[ stream) > (map nil #'(lambda (element) > > _______________________________________________ > cl-json-devel mailing list > cl-json-devel at common-lisp.net > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-json-devel From utsl at quic.net Sun Mar 25 00:31:00 2007 From: utsl at quic.net (Nathan Hawkins) Date: Sat, 24 Mar 2007 20:31:00 -0400 Subject: [cl-json-devel] patch to improve encode-json for lists In-Reply-To: <1174735922.5885.60.camel@trinidad> References: <1174735922.5885.60.camel@trinidad> Message-ID: Yes, that's much better. I've been working too hard lately, and just used the first solution that seemed to work. Yours is obviously a better approach, which isn't too surprising, I've only been hacking in Lisp for a couple of months. I'm using cl-json to bundle up data from SQL requests into JSON for a Javascript rpc client, so I really wanted a way to get lists of objects on the Javascript end. Thanks, Nathan On 3/24/07, Henrik Hjelte wrote: > > On Thu, 2007-03-22 at 08:56 -0400, Nathan Hawkins wrote: > > This fairly simple patch seems to enable encode-json to handle alists. > Thanks. I added your first example as a testcase, > test-encode-json-nathan-hawkins > > (defvar *foo* '((a . 1) (b . 2) (c . 3))) > (encode-json-to-string *foo*) > --> "{\"a\":1,\"b\":2,\"c\":3}" > > When I added your patch several other tests broke. There is a problem > with you code that you guess the type of of the list from the first > element. So I instead made a solution that works with your code and > doesn't break any tests. It is in darcs now. > > Also, I have added Pascal Bourguignons patch to darcs, so beware that > json.asd is now renamed cl-json.asd. > > Thanks, > Henrik > > > > > ;; normal lists still work > > (defvar *bar* '(1 2 3 4 5)) > > (encode-json-to-string *bar*) > > --> "[1,2,3,4,5]" > > > > ;; messed up lists of alists which contain lists also works now > > (defvar *baz* '(((a . 1) (b .2) (c . 3) (d . (1 2 3 4 5))))) > > (encode-json-to-string *baz*) > > --> "[{\"a\":1,\"b\":[0.2],\"c\":3,\"d\":[1,2,3,4,5]}]" > > > > ;; even better, decode-json likes the output > > (decode-json-from-string "[{\"a\":1,\"b\":[ 0.2],\"c\":3,\"d > > \":[1,2,3,4,5]}]") > > --> (((:A . 1) (:B 0.2) (:C . 3) (:D 1 2 3 4 5))) > > > > One thing you can't do is encode a list appended to an alist. That > > won't work, and I don't know how you'd > > encode it in JSON anyway. > > > > Someone who's had way more sleep than I have lately should test this > > as well. But I can now both encode > > and decode lists of alists, which scratches my particular itch... > > > > Nathan > > > > diff -rN -u old-cl-json/src/encoder.lisp new-cl-json/src/encoder.lisp > > --- old-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 > > -0400 > > +++ new-cl-json/src/encoder.lisp 2007-03-21 23:29:22.000000000 > > -0400 > > @@ -25,6 +25,12 @@ > > (t (write-json-string (funcall *symbol-to-string-fn* s) > > stream)))) > > > > (defmethod encode-json((s sequence ) stream) > > + (if (and (consp (car s)) > > + (atom (cdar s))) > > + (encode-json-alist s stream) > > + (encode-json-list s stream))) > > + > > +(defun encode-json-list (s stream) > > (let ((first-element t)) > > (write-char #\[ stream) > > (map nil #'(lambda (element) > > > > _______________________________________________ > > cl-json-devel mailing list > > cl-json-devel at common-lisp.net > > http://common-lisp.net/cgi-bin/mailman/listinfo/cl-json-devel > > -------------- next part -------------- An HTML attachment was scrubbed... URL: