Deserialize bug 2.0.0-alpha6
See original GitHub issueImagine the following class:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Nationality { get; set; }
public bool Married { get; set; }
}
When serializing the following Person
…
var person = new Person{ FirstName = "John", LastName = "Doe" };
serializer.Serialize(person);
The following XML is generated (more or less):
<Person>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
<Married>false</Married>
</Person>
And everything is OK with the world, deserializing works properly too etc etc.
But now imagine this scenario:
var person = new Person{ FirstName = "John", LastName = string.Empty, Nationality = "British", Married = true };
serializer.Serialize(person);
This will produce the following XML:
<Person>
<FirstName>John</FirstName>
<LastName></LastName>
<Nationality>British</Nationality>
<Married>true</Married>
</Person>
Which also looks exactly what it should like. However when I try to deserialize that… I end up with a Person
where LastName == string.Empty
, Nationality == null
and Married == false
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Can't deserialize. undefined method `[]=' for nil:NilClass
I believe this may be a bundler bug. It is using rails gem from git source but activerecord from the actual gem when...
Read more >WCF Error in deserializing body of request message for ...
Two questions: Why do you create a GetCapabilitiesRequest object which contains a subobject GetCapabilities , and then in your method call, ...
Read more >keywords:JSON Deserialize
This package can serialize OpenLayers style instances into javascript objects, and deserialize javascript objects into OpenLayers style instances. openlayers ...
Read more >deer-macros - crates.io: Rust Package Registry
deer is an experimental backend-agnostic deserialization framework for Rust, featuring meaningful error messages and context (utilizing ...
Read more >bson - npm Package Overview - Socket.dev
Serializes an object to an Extended JSON string, and reparse it as a JavaScript object. EJSON.deserialize(ejson, [options]). Param, Type ...
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
OK this was due to how we’re using the native
XmlReader
and extracting the value from that. I have checked in a fix. @wojtpl2 I noticed we haven’t pushed Alpha 7 yet. Were we supposed to? I forget. 😆 Last I remember I was going to work on v2.0 documentation, which I hope to start up tomorrow and have done next week.I am thinking we should get this fix in with an Alpha 7 push when you find the time. 👍
This has been fixed in the latest versions. Please feel free to comment on this issue (or open another issue) if there is any outstanding/expected work if not. Thanks again for your participation, @FaustoNascimento!