// ToValues converts a Content type to a *Values to use with a Ponzu Go client.
ToValues converts a Content type to a *Values to use with a Ponzu Go client.
// ToValues converts a Content type to a * Values to use with a Ponzu Go client .
func ToValues(p interface{}) (*Values, error) {
	j, err := json.Marshal(p)
	if err != nil {
		return nil, err
	}
	var kv map[string]interface{}
	err = json.Unmarshal(j, &kv)
	if err != nil {
		return nil, err
	}
	vals := NewValues()
	for k, v := range kv {
		switch v.(type) {
		case []interface{}:
			vv := v.([]interface{})
			for i := range vv {
				vals.Add(k, fmt.Sprintf("%v", vv[i]))
			}
		default:
			vals.Add(k, fmt.Sprintf("%v", v))
		}
	}
	return vals, nil
}
func ToValues ( p interface { } ) ( * Values , error ) { j , err := json . Marshal ( p ) if err != nil { return nil , err } var kv map [ string ] interface { } err = json . Unmarshal ( j , & kv ) if err != nil { return nil , err } vals := NewValues ( ) for k , v := range kv { switch v . ( type ) { case [ ] interface { } : vv := v . ( [ ] interface { } ) for i := range vv { vals . Add ( k , fmt . Sprintf ( " " , vv [ i ] ) ) } default : vals . Add ( k , fmt . Sprintf ( " " , v ) ) } } return vals , nil }
ToValues converts a Content type to a *Values to use with a Ponzu Go client.
ToValues converts a Content type to a * Values to use with a Ponzu Go client .
// encode p to JSON // decode json to Values