Ejemplo n.º 1
0
func convertObject(input *otto.Object) map[string]interface{} {
	output := map[string]interface{}{}
	if input == nil {
		return output
	}

	for _, key := range input.Keys() {
		v1, _ := input.Get(key)

		var trueValue interface{}
		if v1.IsBoolean() {
			trueValue, _ = v1.ToBoolean()
		} else if v1.IsNumber() {
			trueValue, _ = v1.ToInteger()
		} else {
			trueValue = v1.String()
		}

		output[key] = trueValue
	}

	return output
}