Open dynaxis opened 6 years ago
Let me elaborate more on it. In my case, I have a struct and some more fields outside it that should be added only to JSON. So I created an outer struct with the additional fields and the original struct embedded as a pointer. So when I unmarshall it, I set pointer to the original struct to the outer struct and expect the pointer kept in tact filling data from JSON into it.
As a workaround, I'm currently copying the unmarshalled inner-struct to the struct that is passed into unmarshall methods.
In the case of
encoding/json
, if I setInner
ofTest
struct before unmarshalling, it is kept after unmarshalled. But in the case of easyjson, the generated implementation unconditionally donew(Inner)
and assign to theTest.Inner
.If there is no particular reason for doing it unconditionally, it would be good if
easyjson
works the same way asencoding/json
.Thanks.