Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent encoding of objects in a list #334

Closed
Almenon opened this issue Dec 23, 2020 · 2 comments
Closed

Inconsistent encoding of objects in a list #334

Almenon opened this issue Dec 23, 2020 · 2 comments

Comments

@Almenon
Copy link
Contributor

Almenon commented Dec 23, 2020

After the fourth object the encoding strategy differs - see Almenon/AREPL-backend#163

Is there a reason for this? I'm not sure if it's intentional or not.

davvid added a commit to davvid/jsonpickle that referenced this issue Jan 14, 2021
Previously the make_refs=False / unpicklable=False code path
would avoid emitting data for objects it had already seen.
It mostly did this to avoid cycles, as its reference
system is disabled in these modes, and thus the result
was that null was emitted for any objects that appear
more than once in the object graph.

Improve the behavior by keeping track of objects that we
have already flattened and simply return the pre-flattened
representation when we re-encounter the same object.

This is a simple solution that fixes encoding of datetime
objects with UTC tzinfo in these scenarios.

Resolves jsonpickle#333 jsonpickle#334 jsonpickle#337
Signed-off-by: David Aguilar <davvid@gmail.com>
@davvid
Copy link
Member

davvid commented Jan 14, 2021

Please test the proposed changes in #338 and let me know if it fixes things for your use case.

davvid added a commit to davvid/jsonpickle that referenced this issue Jan 14, 2021
Previously the make_refs=False / unpicklable=False code path
would avoid emitting data for objects it had already seen.
It mostly did this to avoid cycles, as its reference
system is disabled in these modes. The end result was that null
was emitted for any objects that appear more than once in the
object graph.

Improve the behavior by keeping track of objects that we
have already flattened and return the pre-flattened
representation when we re-encounter the same object.

This is a simple solution that fixes encoding of datetime
objects with UTC tzinfo in these scenarios.  It also improves
encoding of objects with multiple references to the same
object as the object will now be properly encoded each
time it is encountered in the object graph.

Resolves jsonpickle#333 jsonpickle#334 jsonpickle#337
Signed-off-by: David Aguilar <davvid@gmail.com>
@Almenon
Copy link
Contributor Author

Almenon commented Jan 15, 2021

Now the encoding strategy is consistent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants