Anonymous types are not getting properly serialized
See original GitHub issueThe below request gets converted,
var extendedData = new[]
{
new { Name = "foo", Value = 1 },
new { Name = "bar", Value = 2 },
};
request.ExtendedData = extendedData;
into following JSON
{"Data":"test","Monitoring":true,"ExtendedData":[{},{}]}
with SafeJsonConvert.SerializeObject. It works as expected with JsonConvert.Serialize method of JSON.NET.
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
c# - Serializing anonymous types - Stack Overflow
As such, anonymous types are not marked as serializable. Since the usage of binary serialization means you later on want to deserialize them,...
Read more >Deployment Issue: Serialization Exception on Anonymous Type
The anonymous type I'm returning is the result of a LINQ to Entities query that uses a Select method to build the anonymous...
Read more >Serialized anonymous classes using JsonUtility - Unity Forum
Most serializers require the class that is serialized to be marked with the System.Serializable attribute. Anonymous classes do not have this ...
Read more >Casting object to Anonymous Types in C# - Mitch Valenta
In my test, I wanted to validate the data on one of the models in that anonymous type that is set in IActionResult's...
Read more >On Lambdas, Anonymous Classes and Serialization in Java
One important aspect of serialization is that it does not apply to single instances but to graphs of objects. There is little value...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve just found this and solved it by created a CustomInitialize that changes the contract resolver.
My code is now working!
Thanks for the details @keerthivasanm
I’ve made sure this issue is being triaged by the right people.
FYI @markcowl