Consider simplifying JSON option input #1732
-
Currently we have commands that take a JSON string as an input, an example of this is the In PowerShell, to read the contents of a JSON file and pass a JSON string into the command you have to perform some sanitisation of the JSON string before it is parsed as being valid JSON by the command. $sitescript = Get-Content -Path .\sitescript.json | ConvertFrom-Json | ConvertTo-Json -Compress
$sitescript = '`"{0}"`' -f $sitescript.Replace('"', '""')
o365 spo sitescript add --title "My Script" --content $sitescript Performing the above is not ideal and has been highlighted before in discussion #1311 The Azure CLI gets around this issue by allowing file path to be specified by prepending with the
Thoughts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Working with JSON or any other escaped string in a shell is indeed tough. I'd be all for offering a better experience for it. Rather than using a magic token like |
Beta Was this translation helpful? Give feedback.
Working with JSON or any other escaped string in a shell is indeed tough. I'd be all for offering a better experience for it. Rather than using a magic token like
@
, I'd prefer to expose an additional option that expects a path and have users explicitly choose if they want to specify the string or a path to a file.