emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] json: Add support for encoding structs


From: Clément Pit-Claudel
Subject: Re: [PATCH] json: Add support for encoding structs
Date: Mon, 24 Apr 2017 09:45:28 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 2017-04-23 06:16, Vibhav Pant wrote:
> The following patch to json.el adds support for encoding record types
> declared via cl-defstruct. It also allows the user to change the json
> key for a struct field by using the `:json' keyword while declaring
> a slot.
> 
> An example of the new json-encode:
> ELISP> (cl-defstruct foo (f1 "foo") (f2 "bar" :json "field2"))
> foo
> ELISP> (json-encode (make-foo))
> "{\"f1\":\"foo\",\"field2\":\"bar\"}"

This looks nice, thanks.  Two questions:

* Will this break existing code? Or did the switch to records already break 
things? IIUC serializing a record until now would have serialized the 
underlying vector, whereas in the new code the representation will change.
* Do you plan to add deserializing support, too ?

Thanks!
Clément.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]