You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some issues lately with Serialization of derived C# types using DocumentJsonSerializerOptions .
In Orchard Core you can define the derived types for serialization from this serviceL
services.AddJsonDerivedTypeInfo<derived, base>();
But I noticed lately (this was not happening about a month ago )that when you try to serialize the derived type that has been defined from the startup services that when you serialize it doesn't contain the type info metadata to later on deserialize it back to the derived type.
As an example the following code serializes the ContentDeploymentStep without the type info metadata :
public class TestController : Controller
private readonly JsonSerializerOptions _jsonSerializerOptions;
public TestController (
IOptions<DocumentJsonSerializerOptions> jsonSerializerOptions
)
{
_jsonSerializerOptions = jsonSerializerOptions.Value.SerializerOptions;
}
public Task<IActionResult> Test()
{
var TestDerivedType= new ContentDeploymentStep(){Name = "Test"};
var serialized= JsonSerializer.Serialize(TestDerivedType, _jsonSerializerOptions); //serialized string does not contain the type information
metadata
}
//later on when deserializing back it does not convert to the derived class but to base class
Can someone please confirm if it happens on their side?
This discussion was converted from issue #17091 on November 28, 2024 19:23.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm having some issues lately with Serialization of derived C# types using DocumentJsonSerializerOptions .
In Orchard Core you can define the derived types for serialization from this serviceL
But I noticed lately (this was not happening about a month ago )that when you try to serialize the derived type that has been defined from the startup services that when you serialize it doesn't contain the type info metadata to later on deserialize it back to the derived type.
As an example the following code serializes the ContentDeploymentStep without the type info metadata :
Can someone please confirm if it happens on their side?
Beta Was this translation helpful? Give feedback.
All reactions