From 56a053a61d2fb2cb28e753466f6de1abb9ada3d6 Mon Sep 17 00:00:00 2001 From: Daniel Weiser Date: Wed, 5 Aug 2020 19:29:25 +0300 Subject: [PATCH] UnmarshalJSON refactoring --- v5/types.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/v5/types.go b/v5/types.go index 4b633fa..012a89e 100644 --- a/v5/types.go +++ b/v5/types.go @@ -4,6 +4,7 @@ import ( "encoding/json" "net/http" "reflect" + "strings" ) // ByID is "id" constant to use as `by` property in methods @@ -383,7 +384,8 @@ func (v *OrderDeliveryData) UnmarshalJSON(b []byte) error { field := object.Field(i) if i, ok := field.Tag.Lookup("json"); ok { - delete(additionalData, i[:len(i)-10]) + name := strings.Split(i, ",")[0] + delete(additionalData, strings.TrimSpace(name)) } else { delete(additionalData, field.Name) }