Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Cmdlet

ConvertFrom-OfficeToml

Module
PSWriteOffice
Inputs
System.String
Outputs
System.Management.Automation.PSObject System.Collections.Specialized.OrderedDictionary

Converts TOML text to PowerShell objects, as ConvertFrom-Json does for JSON.

Syntax

ConvertFrom-OfficeToml
[-AsHashtable]
[-Depth <Int32>]
[-InputObject] <String>
[-Untrusted]
[<CommonParameters>]
#
Parameter set: InputObject

Description

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.dependencies

List 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 optional
Return tables as ordered hashtables instead of PSCustomObjects.
-Depth Int32 optional
Deepest nesting of tables and arrays to accept; sets the reader's MaxDepth.
-InputObject String requiredposition: 0pipeline: True (ByValue)
TOML text; piped strings are joined with line breaks before parsing.
-Untrusted SwitchParameter optional
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.