fix: fix alchemy collectible traits parsing

This commit is contained in:
Dario Gabriel Lipicar 2023-11-16 15:12:32 -03:00 committed by dlipicar
parent 2c55b9c676
commit 92a604f471
1 changed files with 10 additions and 4 deletions

View File

@ -81,19 +81,25 @@ type RawMetadata struct {
Attributes []Attribute `json:"attributes"`
}
type RawFull struct {
RawMetadata RawMetadata `json:"metadata"`
}
type Raw struct {
RawMetadata interface{} `json:"metadata"`
}
func (r *Raw) UnmarshalJSON(b []byte) error {
metadata := RawMetadata{
Attributes: make([]Attribute, 0),
raw := RawFull{
RawMetadata{
Attributes: make([]Attribute, 0),
},
}
// Field structure is not known in advance
_ = json.Unmarshal(b, &metadata)
_ = json.Unmarshal(b, &raw)
r.RawMetadata = metadata
r.RawMetadata = raw.RawMetadata
return nil
}