Closed wardbradt closed 5 years ago
Closed because after looking at gojay's code I have found that this behavior is not yet available in the library. I think it would be a non-negligible task to extend the functionality of the library to do this as the architecture seems to be not designed for such a use case.
If I have a stream of JSON messages coming in as
[]byte
, with some messages having"foo"
as a key and some with"bar"
as key, how can I Unmarshal the "foo" messages into one type of struct and the "bar" messages into another?Given the example in the README:
I believe the logic needs to be in
UnmarshalStream
. However, I am not sure how to determine what value of what type should be passed todec.Object
.Note: This is a simplified example, I need to solve this for >5 types of messages.