rudolph-miller / jonathan

JSON encoder and decoder.
http://rudolph-miller.github.io/jonathan/overview.html
164 stars 24 forks source link

Output JSON properties that are not ALLCAPS. #68

Open dbarros opened 3 years ago

dbarros commented 3 years ago

Is it possible to configure jonathan so that it can output, and parse, JSON that has properties that are not in ALLCAPS?

For example, the JSON may use all lowercase for property name, or camelCase, or snake_case. e.g.:

{ "first_name": "Charlie"; }

or

{ "firstName": "Charlie"; }

jg20019 commented 2 years ago

Yes. One way you can do it is to when you output json, you use write-key-value and with-object directly. There is an example on this page: http://rudolph-miller.github.io/jonathan/. You can find it in the example, where you define a method to-json to output a user class as json

jg20019 commented 2 years ago

I found a better way:

(jonathan:to-json '(("first_name" . "charlie")) :from :alist)