[英]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.