Skip to content

Instantly share code, notes, and snippets.

@drlongnecker
Created December 12, 2010 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drlongnecker/737845 to your computer and use it in GitHub Desktop.
Save drlongnecker/737845 to your computer and use it in GitHub Desktop.
Odd formatting with PowerShell and Json
Doesn't work:
$data = "`"{'message':{'body':'{0} - {1}'}}`"" -f $message, $url
Throws:
Error formatting a string: Input string was not in a correct format..
At Script.ps1:11 char:50
+ $data = "`"{'message':{'body':'{0} - {1}'}}`"" -f <<<< $message, $url
+ CategoryInfo : InvalidOperation: (System.Object[]:Object[]) [], RuntimeException
+ FullyQualifiedErrorId : FormatError
Works:
$data = "`"{'message':{'body':'" + $message + " - " + $url + "'}}`""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment