Share Link
Copied to clipboard
Embed on Your Page
Copied to clipboard
We Stand with Ukraine
https://stackoverflow.com/questions/78391873/allow-multiple-types-for-one-property-when-deserializing-json-using-syste-text-j?noredirect=1#comment138202747_78391873 by dbc_MinLength
Environment version: .NET 9.0.0 (9.0.0), Unix 6.8.0.1014
System.Text.Json version: System.Text.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

Value is hello
{"values":{"type":1,"value":"hello"}}

Value is 1,2,3.
{
  "values": {
    "type": 2,
    "value": [
      1,
      2,
      3
    ]
  }
}
Cached Result
Last Run: 3:15:44 pm
Compile: 0.061s
Execute: 0.14s
Memory: 10.84Mb
CPU: 0.201s