amazon-ion / ion-go

A Go implementation of Amazon Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
174 stars 31 forks source link

Restriction on input struct from user to Unmarshal values with annotation #109

Open R-maan opened 4 years ago

R-maan commented 4 years ago

Unmarshal provides a way to include annotations of Ion values. In order to do so, user needs to send a specific data structure, which is a struct with exactly 2 fields, one with ion:",annotation" tag, and the other a type which can hold the Ion value after decoding (in terms of type).

In the code base, unmarshal.go:

// expected struct for decoding Ion values must have only 2 fields: one has `ion:",annotation"`
// tag, and the other field must be of a type where Ion value can be decoded to.
func isValidAnnotatableStruct(v reflect.Value, listofkinds []reflect.Kind) (bool, error) {