From 68252b965ab30c6920ed89a146b990e79d17b490 Mon Sep 17 00:00:00 2001 From: bteshome Date: Wed, 22 Jan 2020 11:14:59 +0100 Subject: [PATCH] Add support to unmarshal struct containing int slices --- request.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/request.go b/request.go index a7bb0b1..7f5803d 100644 --- a/request.go +++ b/request.go @@ -434,6 +434,22 @@ func unmarshalAttribute( return } +func handleIntSlice( + attribute interface{}, + fieldType reflect.Type, + fieldValue reflect.Value) (reflect.Value, error) { + + v := reflect.ValueOf(attribute) + + values := make([]int, v.Len()) + for i := 0; i < v.Len(); i++ { + ve := v.Index(i) + values[i] = int(ve.Interface().(float64)) + } + + return reflect.ValueOf(values), nil +} + func handleStringSlice(attribute interface{}) (reflect.Value, error) { v := reflect.ValueOf(attribute) values := make([]string, v.Len())