| 34 | } |
| 35 | |
| 36 | func Decode(data []byte, dst *sheets.CellFormat) error { |
| 37 | if dst == nil { |
| 38 | return errFormatRequired |
| 39 | } |
| 40 | |
| 41 | dec := json.NewDecoder(bytes.NewReader(data)) |
| 42 | dec.DisallowUnknownFields() |
| 43 | |
| 44 | if err := dec.Decode(dst); err != nil { |
| 45 | return fmt.Errorf("decode cell format: %w", err) |
| 46 | } |
| 47 | |
| 48 | var extra any |
| 49 | if err := dec.Decode(&extra); err != io.EOF { |
| 50 | if err == nil { |
| 51 | return errMultipleJSONValues |
| 52 | } |
| 53 | |
| 54 | return fmt.Errorf("decode trailing cell format data: %w", err) |
| 55 | } |
| 56 | |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | func NormalizeMask(mask string) (string, []string) { |
| 61 | parts := splitFieldMask(mask) |