gabs icon indicating copy to clipboard operation
gabs copied to clipboard

If i want to detect the type array or object ,how to differentiate ?

Open chandraanwar91 opened this issue 4 years ago • 1 comments

chandraanwar91 avatar Jul 05 '20 05:07 chandraanwar91

Hey @chandraanwar91, the underlying value of an array or object is always []interface{} and map[string]interface{} respectively, therefore you can do something like this this for type switching:

switch gObj.Data().(type) {
case []interface{}:
  // TODO
case map[string]interface{}:
  // TODO
default:
  // TODO
}

Jeffail avatar Jul 21 '20 17:07 Jeffail