-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLOS #13
Comments
Interestingly enough - if you remove the with-decoder line - run the code once, and add it back in, it starts to work :) So far - that's my excuse for not attempting to give it a fix. |
Hi!
I tried too, and can confirm the behavior, this is kind of crazy!
I think i can understand you! 😄 Bye! |
Hi! Seems that adding (progn
(mapcar #'finalize-inheritance superclasses) ; added this form
(make-instance 'fluid-class ...)) here, solves the issue; but because, unfortunately, I know near nothing about MOP, i do not think would be a good idea to suggest this code as a proper patch. Any MOP expert wold wants to help? Bye! |
You picked my interest, and I started digging around and reading up on MOP. As far as i could tell - your solution wouldn't be too bad either, might run an extra time or two (depending on how many classes you've got) in case if custom classes are involved i'm guessing. And that said i haven't yet checked how my change works with custom classes. (Learned that this package provides a way to have custom classes - i possibly don't have to have a big blob class which describes all possible json keys i am using) Gonna play around a bit more. Also not sure how active the maintainers are and if the MR will even be considered. Anyhow - thanks for the fix @cage2 :) |
Hi @bmiww ! Your solution is better than mine, my code was just a crude hack and nothing more.
I made a quick test and seems to works just fine! (defpackage :json-clos
(:use :cl
:cl-json)
(:export :main))
(in-package :json-clos)
(defclass test-class ()
((foo
:initform 'foo
:initarg :foo
:accessor foo)
(bar
:initform 'bar
:initarg :bar
:accessor bar)
(baz
:initform 'baz
:initarg :baz
:accessor baz)))
(defmethod print-object ((object test-class) stream)
(print-unreadable-object (object stream)
(format t "foo: ~s bar: ~s baz: ~s" (foo object) (bar object) (baz object))))
(defun main ()
(json:with-decoder-simple-clos-semantics
(let ((instance (json:decode-json-from-string
"{\"foo\": [1, 2, 3], \"bar\": true, \"baz\": \"!\",
\"prototype\": {\"lispPackage\": \"jsonClos\",
\"lispClass\": \"test-class\"}}")))
(format t "~a → ~a~%" (class-of instance) instance))))
You're welcome! Thanks to you to make me remember this report, I learnt something about MOP too! I hope someone will merge your patch soon! Bye! |
Hi!
The CLOS decoder seems does not works anymore, even the code in the documentation:
signals an error:
Bye!
C.
The text was updated successfully, but these errors were encountered: