Reputation: 65
I am trying to decode json data in Common Lisp using the library cl-json. But I have a problem : when using the decode-json-from-string
function, with this data, for example
{"Hello": "world"}
I get a plist that looks like this:
(:*HELLO . "world")
But I want the accessor to be a symbol, not a string.
Upvotes: 1
Views: 221
Reputation:
:*HELLO
is a symbol: it's a symbol in the keyword package. How symbols are turned to and from JSON object keys is described in the manual: the default encode and decoders map object keys onto symbols, doing a lot of fancy camel-case translation. *json-identifier-name-to-lisp*
& *lisp-identifier-name-to-json*
are two variables which hold the default mapping functions, which are camel-case-to-lisp
and lisp-to-camel-case
respectively. *json-symbols-package*
controls the package where interning happens.
You can adjust any or all of these to do what you want.
Upvotes: 3