question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserialize bug 2.0.0-alpha6

See original GitHub issue

Imagine 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:closed
  • Created 6 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Mike-E-angelocommented, Sep 26, 2017

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. 👍

0reactions
Mike-E-angelocommented, Oct 18, 2017

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found