We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Here is what to include in your request to make sure we implement a solution as quickly as possible.
System.Text.Json.JsonSerializer.Serialize return {} .
// .NET 5 ~ .NET 7 IList<DynamicProperty> properties = new List<DynamicProperty>(); properties.Add(new DynamicProperty("A",typeof(string))); DynamicClassFactory.CreateType(properties); var type = DynamicClassFactory.CreateType(properties); var list = new List<DynamicClass>(); DynamicClass dynamicClass = Activator.CreateInstance(type) as DynamicClass; dynamicClass.SetDynamicPropertyValue("A", "A"); var text = System.Text.Json.JsonSerializer.Serialize(dynamicClass); // return {},expected {"A":"A"} var text = System.Text.Json.JsonSerializer.Serialize(dynamicClass,typeof(object)); //return {"A":"A"} OK What happened? var text2 = Newtonsoft.Json.JsonConvert.SerializeObject(dynamicClass) //return {"A":"A"} OK
The text was updated successfully, but these errors were encountered:
@ryanryanorient This seems like a (breaking) change in System.Text.Json? Did also post your question there?
Sorry, something went wrong.
Solutions for this are:
var text = System.Text.Json.JsonSerializer.Serialize(dynamicClass, typeof(object)); var text = System.Text.Json.JsonSerializer.Serialize(dynamicClass, dynamicClass.GetType()); var text = System.Text.Json.JsonSerializer.Serialize(dynamicClass, type);
#679
Hello @ryanryanorient,
I'm closing this issue for now, can you maybe create an issue in the System.Text.Json GitHub for this?
StefH
No branches or pull requests
Here is what to include in your request to make sure we implement a solution as quickly as possible.
1. Description
System.Text.Json.JsonSerializer.Serialize return {} .
2. Exception
System.Text.Json.JsonSerializer.Serialize return {} .
3. Fiddle or Project
The text was updated successfully, but these errors were encountered: