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

Is it possible to defer unmarshaling? #20

Open
whyrusleeping opened this issue Jan 11, 2018 · 1 comment
Open

Is it possible to defer unmarshaling? #20

whyrusleeping opened this issue Jan 11, 2018 · 1 comment

Comments

@whyrusleeping
Copy link
Collaborator

I basically want the equivalent of https://golang.org/pkg/encoding/json/#RawMessage

I can look at implementing this if its not already possible.

@warpfork
Copy link
Member

warpfork commented Jan 13, 2018

Nothing like it yet.

One implementation approach that might be interesting would be storing a []Token, in contrast to json.RawMessage's []byte approach. This would save tokenizing twice, assuming you're going to parse it later. On the other hand, the memory overhead might not be great; the token type is defined with a ton of fields and expected to be used like a union, because the way things work right now there's only ever one of the allocated and it's just used to pass messages back and forth. So, maybe it depends on what you're doing.

If you're angling to do something like http://eagain.net/articles/go-json-kind/ with this, there might be other options: docs/dev/code-layout.md proposed things like unmarshalMachinePolymorphicEnvelope, which also still needs implementation work, but would probably be the cleanest solution to those sorts of use case.

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