PowerShell Snippets: Format Json for Curl

PowerShellThis post is part of the series on PowerShell Snippets.

The following PowerShell shows the format required for use in Curl (which I will cover in the next post of this series). It took me a number of attempts to get the format correct; the backticks (`) are needed to escape the double quotes (") for PowerShell and the backslashes (\) to escape them for the curl command:

$json = "
    { \`"tag_name\`": \`"$ghTag\`", \`"target_commitish\`": \`"main\`", \`"name\`": \`"$ghTag\`", \`"body\`": \`"$ghTag release\`", \`"draft\`" :false, \`"prerelease\`": false, \`"generate_release_notes\`": false }
"

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *