Releases: weberr13/go-decode
Added setting default values using a new API
This release adds the ability to set default values to decoded fields.
Defaults are assigned for fields of basic types (int/float/string) that have the correct struct tag (default:"value"
)
Default behavior is not to assign defaults. To assign default, users call new API UnmarshalJSONIntoWithDefaults
of DecodeIntoWithDefaults
Allow null for non-required fields
Merge pull request #13 from weberr13/ignore-unrequired-nil Ignore nil value for unrequired fields
Fix nil value check for json null's
Merge pull request #12 from weberr13/fix-panic-on-null Add check and return error for nil value
Support Arrays of pointers and Unmarshaler interface
Merge pull request #10 from weberr13/set-field-with-unmarshaler Add method to parse underlying type into object
Handle invalid field in decodeIntoArray
Problem: Passing an invalid field (an empty array where there should be a struct) as a part of a request to DecodeInto was causing a panic in decodeIntoArray.
Solution: As a part of the block that checks the field.Kind() type, if none of the three types is discovered, an error string is returned so that it gets handled, rather than panicking on a nil value later on.
Testing (optional if not described in Solution section): A unit test mimicking this issue has been added to decode_test.go
Support required (non-pointer) fields in DecodeInto
Add support for what are required fields in oapi-codegen, E.G. Non-pointers in the structs.
Introduced DecodeInto using SchemaPathFactory and related
Added support for per type factory reachable using a single path factory.
Path defined as SchemaName.propertyName
No more Decodable interface
Go type assertions must be bidirectional so I cannot use Decodable the way I would like.
Kind -> Discriminator
v0.0.2 Kind is way to generic for the interface. Discriminator is less like…