Utility to interact with a stream of newline delimited JSON
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

16 lines
347 B

package jsonstream
import (
"fmt"
"reflect"
)
func getAsMap(data interface{}) (fields map[string]interface{}, err error) {
switch value := data.(type) {
case map[string]interface{}:
fields = value
default:
err = fmt.Errorf("Unexpected data type '%s', expected 'map[string]interface{}'.", reflect.TypeOf(value))
}
return fields, err
}