Hi,
I find the concept of allowing the remote party to specify the lisp
class/package into which a JSON object should be decoded interesting. I
think it allows for objects at any nesting level to be decoded to the
correct lisp class and can be powerful. In my opinion this also introduces
some coupling of the internal service implementation, like class and
package names, with the remote client. But it also requires control over
the remote JSON object structure, which may work for a JS script that is
owned by the same service, but doesn't seem to work for a third-party
service API.
In my case I'm trying to use cl-json to decode several types of third-party
service API's objects, e.g. an oauth server's response, a geocoding
response, etc, and I'd like for cl-json to decode the class for me, instead
of either
- doing a manual transformation for each object,
- adding a json-to-class utility outside of cl-json,
- pre-processing the JSON object to add the expected "prototype" fields
before cl-json:decode, which seems like a hack
Basically, I'd like to know if I can do something like:
(cl-json:decode-json-from-source *stream* my-class)
Is this possible in CL-JSON?
I am also aware of JSON-MOP, but it currently doesn't support inherited
class slots and I'd like to avoid introducing another dependency just to
decode to my intended lisp object.
Thanks,
Ernesto