| 95 | } |
| 96 | |
| 97 | func InferMask(data []byte) (string, []string, error) { |
| 98 | var raw map[string]any |
| 99 | dec := json.NewDecoder(bytes.NewReader(data)) |
| 100 | dec.UseNumber() |
| 101 | |
| 102 | if err := dec.Decode(&raw); err != nil { |
| 103 | return "", nil, fmt.Errorf("decode format JSON: %w", err) |
| 104 | } |
| 105 | |
| 106 | var extra any |
| 107 | if err := dec.Decode(&extra); err != io.EOF { |
| 108 | if err == nil { |
| 109 | return "", nil, errMultipleJSONValues |
| 110 | } |
| 111 | |
| 112 | return "", nil, fmt.Errorf("decode trailing format JSON data: %w", err) |
| 113 | } |
| 114 | |
| 115 | paths := make([]string, 0) |
| 116 | collectJSONLeafPaths("", raw, &paths) |
| 117 | sort.Strings(paths) |
| 118 | |
| 119 | if len(paths) == 0 { |
| 120 | return "", nil, ValidationError("format JSON did not contain any format fields") |
| 121 | } |
| 122 | normalized, formatPaths := NormalizeMask(strings.Join(paths, ",")) |
| 123 | |
| 124 | return normalized, formatPaths, nil |
| 125 | } |
| 126 | |
| 127 | func ApplyForceSendFields(format *sheets.CellFormat, formatPaths []string) error { |
| 128 | if format == nil { |