xxxxxxxxxx
package helpers
import "encoding/json"
func KeyExist(input interface{}) (int, error) {
received := make(map[string]interface{})
mapsArr := []string{}
stringify, err := json.Marshal(&input)
if err != nil {
return -1, err
}
if err := json.Unmarshal(stringify, &received); err != nil {
return -1, err
}
for i, _ := range received {
mapsArr = append(mapsArr, i)
}
return len(mapsArr), nil
}