Closed AmirHJabari closed 7 months ago
Thanks for the finding. The optimization to skip null is only called when dealing with the object property directly and not with collection items. This should be an easy fix.
@AmirHJabari , can you try using List or IList to see if the behavior is similar in your test. I will take a look at it over the weekend when I get a chance. Thanks
@rpgmaker sure. Tested with this code and resulted to the same error.
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
var p = new Person()
{
Id = 1,
Addresses = new List<Address> { new Address(), null, new Address() }
};
var json = NetJSON.NetJSON.Serialize(p);
var p2 = NetJSON.NetJSON.Deserialize<Person>(json); // <======= Error
Console.WriteLine("Hello, World!");
}
}
public class Person
{
public int Id { get; set; }
public List<Address> Addresses { get; set; } // basically any class type
}
public class Address
{
public int Id { get; set; } = 1;
}
}
Thanks for verifying. I should be able to resolve it this weekend.
That would be great thank you.
Sorry, I dropped off for a bit. I will be reviewing all the current open items. Thanks
@AmirHJabari , I have fixed the issue. I will push it to a new version once i fix the other open issues. Thanks again for the patience. It was a minor issue with checking for null during deserialization, i was incrementing by 3 characters to skip null instead of 4 characters.
@AmirHJabari , I have pushed the changes to version 1.4.4. Please test again and reopen if it is still an issue. Thanks
Hello as you can see in this simple example there is a major error. Basically, having null in an array of class types. @rpgmaker @wmjordan