cnabio / cnab-go

A Go implementation of CNAB Core 1.0
MIT License
69 stars 37 forks source link

Fix unmarshal for claim results #283

Closed carolynvs closed 2 years ago

carolynvs commented 2 years ago

Originally we were defining output metadata as a map[string]interface{}, and then just casting as needed any output metadata values to map[string]string. This worked fine when setting and then immediately checking values, because we set the metadata correctly to begin with.

When a result is unmarshaled though, the json decoder is unmarshaling the output metadata values as map[string]interface{} and this prevented the helper methods for reading the metadata from working.

I've updated the OutputMetadata type to be map[string]map[string]string so that we aren't relying on casts working, and to give the json decoder the hint it needs to initialize the types correctly.