Closed ken5scal closed 5 years ago
You can make this work, but it is not natively supported by the library. This means you have to write some code to do this, leveraging what the library provides.
Currently, the library assumes that you know the structure of what you want to decode into, or it will allow you decode into a generic container (e.g. map, slice, etc). The only escape hatch is the "Raw" type.
Your best bet might be one of the following:
Hope this helps.
This question is a bit similar to #138. I want to decode a value which would have a different structure based on another field. For example, say I have
SomeObject
in whichStatement
field can use multiple structures depending onFmt
value. In other words, you would not know the structure ofStatement
untilFmt
value is evaluated. Wouldugorji/go/codec
be able to carry out such decoding?