EventFlow icon indicating copy to clipboard operation
EventFlow copied to clipboard

Replace JSON.NET with System.Text.Json

Open DavidRouyer opened this issue 6 years ago • 9 comments

.NET Core 3.0 is coming with the new System.Text.Json API with much better performance than JSON.NET, what do you think of replacing it with the new API?

DavidRouyer avatar Sep 04 '19 19:09 DavidRouyer

You can use it today already, simple provide an implementation that implements IJsonSerializer and EventFlow will use that instead.

Right now EventFlow targets .NET Framework 4.5.2 and System.Text.Json requires 4.6.1. I'm not sure that increasing the framework requirement for improved performance is a good idea, especially when you can change the implementation.

Might consider using different JSON implementations for different frameworks, i.e., System.Text.Json for .NET Standard and then JSON.NET for .NET Framework.

rasmus avatar Sep 05 '19 16:09 rasmus

Might consider using different JSON implementations for different frameworks, i.e., System.Text.Json for .NET Standard and then JSON.NET for .NET Framework.

Looks good to me 👍

DavidRouyer avatar Sep 05 '19 18:09 DavidRouyer

One thing to bear in mind is that STJ doesnt necessary have 100% compatibility with json.net conventions and doesn't honor json.net Converters that one might be reliant on. The choice of serializer and settings is definitely not something one'd want to happen without an explicit change somewhere - i.e. I'd expect to at least need to change a line of code to opt in.

bartelink avatar Sep 05 '19 18:09 bartelink

@bartelink agree

rasmus avatar Sep 06 '19 17:09 rasmus

I have submitted PR #760 that allows for more flexible use of serializers, basically not just lock in one string based serialization. I'm very much interested in your feedback.

tedvanderveen avatar Jun 02 '20 21:06 tedvanderveen

how are things progressing re System.Text.Json? I am corrently working on a project that uses System.Text.Json as primary JSON serialization library, but I still have to duplicate large portions of JSON serialization/deserialization logic to be able to use EventFlow, which is kinda pain in the butt.

Yaevh avatar May 18 '21 23:05 Yaevh

@Yaevh should implementing IEventJsonSerializer be enough?

rasmus avatar May 19 '21 05:05 rasmus

But it something I would like to do for 1.0

rasmus avatar May 19 '21 05:05 rasmus

I've been playing around with System.Text.Json and noticed two differences from Netwonsoft.Json:

  1. System.Text.Json treats empty JSON as invalid and throws JsonException; Newtonsoft.Json deserializes it to null
  2. Newtonsoft.Json can deserialize enum from both int value and name; System.Text.Json handles int value only

Can we live with these limitations?

Yaevh avatar May 21 '21 15:05 Yaevh

Hello there!

We hope you are doing well. We noticed that this issue has not seen any activity in the past 90 days. We consider this issue to be stale and will be closing it within the next seven days.

If you still require assistance with this issue, please feel free to reopen it or create a new issue.

Thank you for your understanding and cooperation.

Best regards, EventFlow

github-actions[bot] avatar Apr 08 '23 13:04 github-actions[bot]

Hello there!

This issue has been closed due to inactivity for seven days. If you believe this issue still needs attention, please feel free to open a new issue or comment on this one to request its reopening.

Thank you for your contribution to this repository.

Best regards, EventFlow

github-actions[bot] avatar Apr 16 '23 09:04 github-actions[bot]