Skip to main content

ConvertTo-JsonArgument

SYNOPSIS​

Convert a powershell hashtable/object to a json escaped string

SYNTAX​

ConvertTo-JsonArgument
[-Data] <Object>
[<CommonParameters>]

DESCRIPTION​

Helper function is used when passing Powershell hashtable or PSCustomObjects to the c8y binary. Before the c8y cli binary can accept it, it must be converted to json.

The necessary character escaping of literal backslash \\ will be done automatically.

If Data parameter is a file path then it is returned as is.

EXAMPLES​

EXAMPLE 1​

ConvertTo-JsonArgument @{ myValue = "1" }

Converts the hashtable to an escaped json string

{\"myValue\":\"1\"}

PARAMETERS​

-Data​

Input object to be converted

Type: Object
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters​

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS​

OUTPUTS​

NOTES​