content: Add format option to transform.Unmarshal

This commit is contained in:
Joe Mooring
2025-08-27 09:16:28 -07:00
committed by GitHub
parent a6a9715961
commit 17f8d33d89
+20 -20
View File
@@ -13,6 +13,26 @@ aliases: [/functions/transform.unmarshal]
The input can be a string or a [resource](g).
### Options
delimiter
: (`string`) Applicable to CSV files. The delimiter used. Default is `,`.
comment
: (`string`) Applicable to CSV files. The comment character used in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored.
format
: {{< new-in 0.149.0 />}}
: (`string`) The serialization format of the input, one of `csv`, `json`, `org`, `toml`, `xml`, or `yaml`. If empty or unspecified, Hugo infers the format from the input. For resources, this option is only needed if the file lacks an extension or to override the inferred format. For strings, it's only required when the format is ambiguous.
lazyQuotes
: {{< new-in 0.122.0 />}}
: (`bool`) Applicable to CSV files. Whether to allow a quote in an unquoted field, or to allow a non-doubled quote in a quoted field. Default is `false`.
targetType
: {{< new-in 0.146.7 />}}
: (`string`) Applicable to CSV files. The target data type, either `slice` or `map`. Default is `slice`.
## Unmarshal a string
```go-html-template
@@ -116,26 +136,6 @@ A remote resource is a file on a remote server, accessible via HTTP or HTTPS.
## Working with CSV
### Options
When unmarshaling a CSV file, provide an optional map of options.
delimiter
: (`string`) The delimiter used. Default is `,`.
comment
: (`string`) The comment character used in the CSV. If set, lines beginning with the comment character without preceding whitespace are ignored.
lazyQuotes
: {{< new-in 0.122.0 />}}
: (`bool`) Whether to allow a quote in an unquoted field, or to allow a non-doubled quote in a quoted field. Default is `false`.
targetType
: {{< new-in 0.146.7 />}}
: (`string`) The target data type, either `slice` or `map`. Default is `slice`.
### Examples
The examples below use this CSV file:
```csv