Closed RenanCarlosPereira closed 3 months ago
@abbasc52, could please also take a look at this PR if not asking too much?
I don't think changing from Newtonsoft
to System.Text.Json
will break anything, any thoughts?
Json parsing is only relevent in 2 places, when user passes workflow as string and secondly in Action context parsing.(I do remember making Action context System.Text.Json compatible)
One major difference is System.Text.Json does not guess type while parsing without a type(by design) .This can lead to some corner cases which might need validation. I will go through the code and report if I see something obvious but old repo had a few asks to migrate and I probably provided reasons.
One way to go forward would be to uncouple json parser as separate extension packages.
Or newtonsoft and other changes can be part of a compatibility nuget, so that main project remains clean and people can migrate as per their convenience.
Nice input @abbasc52
I can cover in unit tests the type s converts
Any ideas on how I can test it?
I don't see any issues moving to System.Text.Json in trying to think in a situation where I can cover in ActionContext
Why the Change?
System.Text.Json
is faster and uses less memory.What’s Different?
Serialization:
JsonConvert.SerializeObject(myObject)
JsonSerializer.Serialize(myObject)
Deserialization:
JsonConvert.DeserializeObject<MyClass>(jsonString)
JsonSerializer.Deserialize<MyClass>(jsonString)
Enum Conversion:
[JsonConverter(typeof(StringEnumConverter))]
[JsonConverter(typeof(JsonStringEnumConverter))]
Other Details
Things to Watch Out For
Newtonsoft.Json
features might not have direct equivalents.JsonSerializerOptions
as needed.