On Wed, May 2, 2018 at 5:54 AM, 'Marcel Franke' via leo-editor <
[email protected]> wrote:

>
> Am Dienstag, 1. Mai 2018 23:07:36 UTC+2 schrieb Edward K. Ream:
>
> Several Leo devs have suggested using json rather than pickle to represent
>> Leo's uA's.
>>
>> Does anyone presently use any uA that can't be serialized into json?
>>
>>
> Not sure whether you are aware about it, but pythons json-module supports
> handling of custom types. json.dumps has the keywords "default" and 'cls"
> for this, and json.loads has *"object_hook" or *"*object_pairs_hook" I
> think (never used them myself).* So as a fallback it's possible to allow
> people to serialize unsupported types by themself, or let the project build
> them when the demand comes. It could even be just used as a worst
> case-fallback, when serializing of faster json-modules failed.
>

​It's good to know this.​


>
> But out the blue I would think date-objects are good candidates for a
> possible unsupported type which people are using.
>

​I've just checked the code for the datetime module.  The date objects are
merely wrappers for a tuple, so creating custom json encoders/decoders
would be easy.

This is not to say that there is a great need to use json for uA's...

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to