![](/img/trans.png)
[英]JSON as Javascript object in Azure http trigger function
[英]JSON Prettifier Using Azure Function w/ PowerShell and HTTP Trigger
以为这很简单,但是a,我无法弄清楚。 看来PowerShell将使用单个cmdlet来美化JSON 。
目标 :使用PowerShell Azure Function应用美化JSON
ConvertToJson
cmdlet进行美化?)并将文件输出回Flow 问题 :
我在下面采取了序列化字符串
'{ "baz": "quuz", "cow": [ "moo", "cud" ], "foo": "bar" }'
在Powershell 3的Prettify json中提到过
这是我与HttpPost一起使用并发送请求的函数:
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
# Interact with query parameters or the body of the request.
$name = $Request.Query.baz
if (-not $name) {
$name = $Request.Body.baz
}
if ($name) {
$status = [HttpStatusCode]::OK
$body = "Hello $name"
}
else {
$status = [HttpStatusCode]::BadRequest
$body = "Please pass a name on the query string or in the request body."
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $status
Body = $body
})
在下面,您可以看到,我可以从我发布的字符串中读取它。
您可以使用ConvertFrom-Json
进行转换,但我想知道您是否还需要它,因为您可以通过以下操作进行访问:
$name = $Request.Query.baz
我的约束力和你一样。 希望能帮助到你。
让我知道您是否仍然需要任何帮助。
您是否正在寻找这样的东西?
using namespace System.Net
param($Request, $TriggerMetadata)
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $Request.RawBody | ConvertFrom-Json | ConvertTo-Json
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.