Azure / Azure/Azure-Functions

Azure Functions V3 Dynamic Serialization

Open
#1,438 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
1.1k
Forks
215
Avg merge
4h 2m
Merged PRs (30d)
1

Description

I've got an azure functions project that takes in an object that has a dynamic property, stores it into cosmos and reads that same object out and returns it as JSON from a HTTPTrigger. Since upgrading to V3 my dynamic property is now malformed in the response.

```[
{
"id": "ck4cn5aox0000s83ab0jwwvl6",
"name": "survey1",
"clientId": 14,
"revisionNumber": 0,
"datasets": [
"managers",
"techs"
],
"sections": [
{
"name": [],
"items": [
{
"prompt": [],
"type": [],
"name": [],
"validators": [
[]
],
"optionsFrom": [],
"allowOther": []
}]
}
]
}
]
```

The sections property is type dynamic and as you can see every property is being returned as an empty array. The nested properties "name", "prompt", "type", etc should be strings, not arrays. The primitive values on the root object serialize fine.

If I downgrade back to functions V2 the JSON serialization works properly I haven't found any documentation that explicitly states that V3 uses the new system.text.json classes I know ASP.Net core has and as AZ Functions is built on top of it's likely it has as well. So my guess is this problem is related to the following: https://github.com/dotnet/corefx/issues/38007.

Seeing as Microsoft doesn't plan to support dynamics in System.Text.Json anytime soon we need a way to switch back to NewtonsoftJson. In ASP.Net core you can switch back by adding `services.AddControllers().AddNewtonsoftJson()` to Startup. It would be helpful for Azure Functions to have some equivalent.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.