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

MapObjectEncoder does not match jsonEncoder #554

Closed
jkanywhere opened this issue Feb 3, 2018 · 1 comment
Closed

MapObjectEncoder does not match jsonEncoder #554

jkanywhere opened this issue Feb 3, 2018 · 1 comment

Comments

@jkanywhere
Copy link
Contributor

Behavior of zapcore.MapObjectEncoder does not match behavior of zapcore.jsonEncoder with respect to OpenNamespace.

MapObjectEncoder.OpenNamespace create a new map and automatically closes the namespace.
jsonEncoder which operates on a single byte buffer in memory and keeps the namespace open.

I will provide example code in the coming days.

jkanywhere added a commit to jkanywhere/zap that referenced this issue Feb 4, 2018
Add test cases to demonstrate uber-go#554,
how jsonEncoder and MapObjectEncoder handle namespaces differently.

Specifically: When foo.MarshalLogObject uses OpenNamespace,
jsonEncoder.AddObject does not close the namespace.
@jkanywhere
Copy link
Contributor Author

I added tests to demonstrate the behavior: jkanywhere#1
Let me know if there is a better way to share that.

sammyrnycreal added a commit to sammyrnycreal/zap that referenced this issue Oct 3, 2021
MapObjectEncoder does not match jsonEncoder
(uber-go#554)

 Problem was that new openNamespaces that are created during AppendObject() call were not closed.

 Note, ONLY new openNamespaces that are created during AppendObject() are closed. If they were created at prior to AppendObject() call, it will remain open till EncodeEntry() call completes.
@abhinav abhinav closed this as completed in b62116b Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants