Skip to content

Nullables with non-default value are serialized in duplicate #137

Closed

Description

@bcarruthers

Thank you for fixing the other nullable issue. When testing, I found another issue when serializing non-default nullable values, which is reproduced in this test:

[TestMethod]
public void NonDefaultNullableValueSerializes()
{
    var obj = new NullableTest { x = 5 };
    var settings = new NetJSONSettings { SkipDefaultValue = true };
    var json = NetJSON.Serialize(obj, settings);
    Assert.AreEqual("{\"x\":5}", json);
}

Expected:<{"x":5}>. Actual:<{"x":5"x":5}>

Activity

  1. rpgmaker commented on Sep 20, 2016

    @rpgmaker
    Owner

    Thanks for the find. The code that is generated had two conditions that writes the property. I need to make sure only one runs.

  2. rpgmaker commented on Sep 21, 2016

    @rpgmaker
    Owner

    Can you please again? Thanks

  3. bcarruthers commented on Sep 21, 2016

    @bcarruthers
    Author

    Looks good, thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions