Skip to content

yason has problem encoding "pure" cons #80

@jcguu95

Description

@jcguu95

Yason does not encode a lisp pure cons (a pure cons is a cons whose cdr is not a cons) into json correctly. For example, an attempt to encode (1 . 2) returns the error.

* (ql:quickload :yason)
* (yason:encode (cons 1 2) *standard-output*)
#<THREAD "main thread" RUNNING {7008680273}>:
  The value
    2
  is not of type
    LIST

This is because (defmethod encode ((object list) ..) treats "pure cons" as lists too,
which seems to be a "feature" of common lisp.

* (defmethod test ((object list)) (pprint object))
#<STANDARD-METHOD COMMON-LISP-USER::TEST (LIST) {7005484C83}>
* (test (cons 1 2))
(1 . 2)

Solutions:

  1. Make it more explicit that "pure cons" are not supported.
  2. Support encoding pure cons.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions