-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object of type 'AtomicInterval' is not JSON serializable #6
Comments
Hi! I will have a look at what is required to support json serialization. That shouldn't be difficult to implement, but maybe there's a more generic way to support different (other) kinds of serialization. I'll keep you in touch. |
It seems there is no "hook" that can be written on
Could you give a try to the latter solution? |
In my case, I use your library in an python Api that communicate in json. So if I use your last solution, I would have to parse the string intervals from JavaScript. Maybe you could generate array of custom object like this : Easy to read, easy to parse, easy to apply from any languages |
The problem is to encode/decode arbitrary objects that could be used as bounds. Integers are supported out of the box by Notice that your example is already "supported" with a bit of Python: >>> i = I.closed(3, 4) | I.closed(7, 9)
>>> [(x.left, x.lower, x.upper, x.right) for x in i]
[(True, 3, 4, True), (True, 7, 9, True)]
>>> v = [(True, 3, 4, True), (True, 7, 9, True)]
>>> I.Interval(*[I.AtomicInterval(*x) for x in v])
[3,4] | [7,9] I can add functions that do this job. They should also accept a parameter to specify how the bounds (arbitrary objects) can be converted from/to built-in data types. For example: >>> i = I.closed(Timestamp(3), Timestamp(4)) | I.closed(Timestamp(7), Timestamp(9))
>>> I.to_data(i, conv=lambda t: t.as_int())
[(True, 3, 4, True), (True, 7, 9, True)]
>>> v = [(True, 3, 4, True), (True, 7, 9, True)]
>>> I.from_data(v, conv=Timestamp)
>>> [Timestamp(3),Timestamp(4)] | [Timestamp(7),Timestamp(9)] |
Yes that will be super great |
I opened a PR (#7). I still need to find why doctest is failing in Python 2.7. |
Closed by #7 |
1.7.0 will be released in a few minutes, with |
Hi
I was wondering if it will be possible to make Interval and AtomicInterval JSON serializable ? 馃檹 馃槃
Thank you in advance
The text was updated successfully, but these errors were encountered: