Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSObject returned from function gets in the way of serialization to JSON #71

Closed
daxian-dbw opened this issue Oct 4, 2018 · 0 comments
Closed
Assignees

Comments

@daxian-dbw
Copy link
Contributor

Objects returned from function run is warpped into PSObject. Further more, the objects in a container object such as array/hastable may also wrapped into PSObject. This makes it not possible to directly use Newtonsoft.Json in the language worker to serailize object to JSON. We need to consider to use ConvertTo-Json for serailizatoin. For deserialization, it should be fine to directly use Newtonsoft.Json APIs.

Repro

run.ps1

param($req)

Write-Verbose "Processing a HTTP request" -Verbose

$output = @{}
$output["GUID1"] = (New-Guid).Guid
$output["GUID2"] = (New-Guid).Guid

# You associate values to output bindings by calling 'Push-OutputBinding'.
return [HttpResponseContext]@{
    StatusCode = 202
    Body = $output
}

function.json

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "type": "http",
      "direction": "out",
      "name": "$return"
    }
  ]
}

Expected Behavior

PS> irm http://localhost:7071/api/HttpStartPS
GUID1 GUID2
----- -----
xxxx  XXX

Actual Behavior

PS> irm http://localhost:7071/api/HttpStartPS
Microsoft.Azure.Functions.PowerShellWorker.HttpResponseContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant