rpgmaker / NetJSON

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

can't deserialize default(DateTime) #162

Closed physhi closed 7 years ago

physhi commented 7 years ago

The problem is that the format of the date in text is "1-01-01 00:00:00.0". The code assumes that the year portion will be 4 characters.

Test case NetJson.DeSerialize(NetJson.Serialize(default(DateTime))

rpgmaker commented 7 years ago

You need to use

NetJSONSetting.DateStringFormat = default: Null

It allows you to customize the serialization and deserialization of custom dates.

physhi commented 7 years ago

The problem is not really with just default(DateTime) but also with default(DateTime).AddMinutes(1).

But I guess, I should use different dateTime serialization as they will be much faster than string serializations (the main reason of using NetJson is speed).

Anyways, great work, with the speed. Even though the code is a bit complex (you are literally working with IL and it becomes hard to follow, but I guess that's the only way to gurantee performance).

On Sun, Apr 23, 2017 at 5:15 PM, Rpgmaker notifications@github.com wrote:

You need to use

NetJSONSetting.DateStringFormat = default: Null

  • This allows customization of date formatting and ignore other formatting option when specified.

It allows you to customize the serialization and deserialization of custom dates.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rpgmaker/NetJSON/issues/162#issuecomment-296499368, or mute the thread https://github.com/notifications/unsubscribe-auth/AGsTgXpPACEaEDLFn74rKoWqgsPH1b8sks5ry-mXgaJpZM4NFlf0 .

rpgmaker commented 7 years ago

Thanks 😀. Working with IL does not guaranteed speed. It is what it generate that does and the unsafe code implementation.

Do you think you can close this issue since you are using the standard date serialization?

Thanks,

rpgmaker commented 7 years ago

Closing this issue. Open if still needed