(value any)
| 153 | } |
| 154 | |
| 155 | func csvDocument(value any) csvOutputDocument { |
| 156 | switch v := value.(type) { |
| 157 | case []any: |
| 158 | return csvOutputDocument{rows: csvRowsFromArray(v)} |
| 159 | case map[string]any: |
| 160 | if rows, metadata, ok := primaryRowsFromMap(v); ok { |
| 161 | return csvOutputDocument{ |
| 162 | metadata: newFlattenedCSVRow(metadata), |
| 163 | rows: csvRowsFromArray(rows), |
| 164 | } |
| 165 | } |
| 166 | return csvOutputDocument{rows: []map[string]string{newFlattenedCSVRow(v)}} |
| 167 | default: |
| 168 | return csvOutputDocument{rows: []map[string]string{scalarCSVRow(v)}} |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | func primaryRowsFromMap(value map[string]any) ([]any, map[string]any, bool) { |
| 173 | if rows, path, ok := primaryRowsAtCurrentLevel(value); ok { |
no test coverage detected