ConvertFrom-OfficeToml
Converts TOML text to PowerShell objects, as ConvertFrom-Json does for JSON.
Syntax
ConvertFrom-OfficeToml
[-AsHashtable]
[-Depth <Int32>]
[-InputObject] <String>
[-Untrusted]
[<CommonParameters>]#InputObjectDescription
Tables become PSCustomObjects with properties in file order (ordered hashtables with AsHashtable), arrays and arrays of tables become arrays, integers Int64, floats Double, and date-times DateTimeOffset (with an offset), DateTime (local date-time or date) or TimeSpan (local time). Piped lines are joined before parsing, so Get-Content output works directly. Depth sets the deepest nesting accepted.
Examples
Read a project manifest's values.
$project = Get-Content -Path ./pyproject.toml -Raw | ConvertFrom-OfficeToml
$project.project.dependenciesList the packages of a Cargo lock file as hashtables.
(Get-Content ./Cargo.lock | ConvertFrom-OfficeToml -AsHashtable).package | ForEach-Object { '{0} {1}' -f $_.name, $_.version }Parameters
- -AsHashtable SwitchParameter
- Return tables as ordered hashtables instead of PSCustomObjects.
- -Depth Int32
- Deepest nesting of tables and arrays to accept; sets the reader's MaxDepth.
- -InputObject String
- TOML text; piped strings are joined with line breaks before parsing.
- -Untrusted SwitchParameter
- Caps every limit at the engine's untrusted defaults, for text from outside.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.