SliceOfLength is a helper method to unmarshal a JSON Array with specified length.
(length int)
| 68 | |
| 69 | // SliceOfLength is a helper method to unmarshal a JSON Array with specified length. |
| 70 | func (p *Partial) SliceOfLength(length int) (a []*Partial, err error) { |
| 71 | err = p.Unmarshal(&a) |
| 72 | if err != nil { |
| 73 | return |
| 74 | } |
| 75 | |
| 76 | if len(a) != length { |
| 77 | err = errors.New("Invalid array length") |
| 78 | } |
| 79 | |
| 80 | return |
| 81 | } |
| 82 | |
| 83 | // Map is a helper method to unmarshal to a JSON Object. |
| 84 | func (p *Partial) Map() (m map[string]*Partial, err error) { |
no test coverage detected