Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Encode symbol cl:null as null #83

Open
kilianmh opened this issue Dec 14, 2023 · 1 comment
Open

Encode symbol cl:null as null #83

kilianmh opened this issue Dec 14, 2023 · 1 comment

Comments

@kilianmh
Copy link

For some more flexibility, it would be neat to have another method encode whith the eql-specifier cl:null. This is also used in some other json parsers.

(defmethod encode ((object (eql 'cl:null)) &optional (stream *json-output*))
  (write-string "null" stream)
  object)

If you like the idea, I will submit the PR.

@phmarek
Copy link
Owner

phmarek commented Dec 18, 2023

Yeah, well, I'm not totally against that idea -- but it might interfere with other users of the library in the same image!

Sadly there's no METHODLET for local methods - the nearest I've come to that is via an additional context parameter that could be hidden by having an encode function that just does (funcall #'encode-via-context *context* object stream) ; then, by locally binding the *context* variable, arbitrary (local!) behaviour can be implemented.

This would be an incompatible change, though (because encode would be a plain function and encode-via-context the generic function) -- and I'm unsure about the runtime performance impact.

Perhaps a yason2 package could do that and just re-use most stuff?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants