// ToResponseItemJSON will try to convert the Response to a ResponseItemJSON, // where the interface value for Item represents a structure that can be // marshaled into basic JSON. func (resp *Response) ToResponseItemJSON() (*ResponseItemJSON, error) { if resp == nil { return nil, errors.New("receiver is nil") } a := attributevalue.AttributeValueMap(resp.Item) c, cerr := a.ToInterface() if cerr != nil { return nil, cerr } resp_json := NewResponseItemJSON() resp_json.ConsumedCapacity = resp.ConsumedCapacity resp_json.Item = c return resp_json, nil }
// ToResponseItemsJSON will try to convert the Response to a ResponsesItemsJSON, // where the interface value for Item represents a structure that can be // marshaled into basic JSON. func (resp *Response) ToResponseItemsJSON() (*ResponseItemsJSON, error) { if resp == nil { return nil, errors.New("batch_get_item.ToResponseItemsJson: receiver is nil") } resp_json := NewResponseItemsJSON() for tn, rs := range resp.Responses { l := len(rs) resp_json.Responses[tn] = make([]interface{}, l) for i, resp_item := range rs { a := attributevalue.AttributeValueMap(resp_item) c, cerr := a.ToInterface() if cerr != nil { return nil, cerr } resp_json.Responses[tn][i] = c } } resp_json.ConsumedCapacity = resp.ConsumedCapacity resp_json.UnprocessedKeys = resp.UnprocessedKeys return resp_json, nil }