❔ Folders
Just starting out with learning c# and I was wondering how do you pull the .json files and convert them into an array?
15 Replies
using Newtonsoft.Json.Link;
JObject json = JObject.Parse(json string);
Avoid using JObject as well as Newtonsoft
please read this
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/how-to?pivots=dotnet-8-0
why avoid newtonsoft?
It's slow as dirt
System.Text.Json is much faster and the recommended option
does jsonserializer do dynamic deserializing?
One should avoid dynamic at all times
That's... unrealistically optimistic.
But yes, it should.
It's fast because it mainly takes use of Spans as well as being source generated.
I'll check it out on my next project
although I don't see how you would check for the existence of an element?
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/use-dom
is always a possibility.
Now. It isn't as fast as serializing directly into a type, but it should be faster than Newtonsoft.
I was going to say... that means it's probably back in the same performance range as newtonsoft's version of the same thing.
but at least it's there. Good to know.
Only one way to test it. BenchmarkDotNet.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.