rpgmaker / NetJSON

Faster than Any Binary? Benchmark: http://theburningmonk.com/2014/08/json-serializers-benchmarks-updated-2/
MIT License
225 stars 29 forks source link

When the `value` is null the `SerializeObject` will throw NullReferenceException #248

Open Mutuduxf opened 8 months ago

Mutuduxf commented 8 months ago

Because SerializeObject is merely a wrapper around Serialize, the type information is obtained by calling value.GetType(). This is not how json serializers are typically used. (Perhaps I do not have enough experience.)

rpgmaker commented 8 months ago

The serialization should does not handle null checks at the moment since it is deferring the usage to the caller. But thanks for mentioning this, I can put a null check in place to avoid the exception.

rpgmaker commented 4 months ago

@Mutuduxf , I have pushed the changes to version 1.4.4. Please test again and reopen if it is still an issue. Thanks

Mutuduxf commented 3 months ago

@Mutuduxf , I have pushed the changes to version 1.4.4. Please test again and reopen if it is still an issue. Thanks

Hi, @rpgmaker , Thanks for your great work. I upgraded to 1.4.4 and tested it, but something interesting has happened. The new code can pass in Net Core, but Framework 4.8 cannot. I have decompiled the dll file from the nuget package (version 1.4.4, net 6.0) and found that there is no new code in it (but it can pass the test in net core!). So I debug the unit test code and step into the source code from NetJson (IDE Rider). In Framework 4.8, there is no new code in it (determine whether it is null in the method SerializeObject), so it cannot pass the tests. But in Net Core, there is an error in the code line positioning (it feels like the problem is with the pdb file). Finally, to verify if there is a problem with my development environment, I launch it in Visual Studio and try it again, and the test results are the same. I am sorry, I am not the collaborator, so I cannot reopen this issue.

rpgmaker commented 3 months ago

That is strange. I wonder if I did not copy the assembly correctly from my machine. I will check it tomorrow. Thanks