Closed afiune closed 6 years ago
Uhhhm I think this answers my question: https://github.com/francoispqt/gojay/blob/master/decode.go#L68
ðŸ˜
So, yes there is no such way at the moment but we could add something that would use standard encoding/json
to decode interface values.
We could also write our own implementation to unmarshal interfaces, performance would be much better but it would take longer.
I thought about both alternatives, let me try to work on the first one since the second one, as you said, will require more time for its implementation.
Is this something you are accepting pull requests?
Yes of course, I'm happy to have contributions :)
Oh cool, I'll work on it.
There are some cases where the JSON data could have different shapes, in those cases we would use an
interface{}
to define a field within a struct.Is it possible for gojay to Decode fields of a struct that are
interfaces{}
?As for instance, this example of an error that has a description with a number of sections that could have different shapes:
How would you implement the
UnmarshalJSONObject()
function?