C
C#2y ago
zyn

❔ 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
TripleTom
TripleTom2y ago
using Newtonsoft.Json.Link; JObject json = JObject.Parse(json string);
TripleTom
TripleTom2y ago
why avoid newtonsoft?
Buddy
Buddy2y ago
It's slow as dirt
Buddy
Buddy2y ago
Buddy
Buddy2y ago
System.Text.Json is much faster and the recommended option
TripleTom
TripleTom2y ago
does jsonserializer do dynamic deserializing?
Buddy
Buddy2y ago
One should avoid dynamic at all times
TripleTom
TripleTom2y ago
That's... unrealistically optimistic.
Buddy
Buddy2y ago
But yes, it should. It's fast because it mainly takes use of Spans as well as being source generated.
TripleTom
TripleTom2y ago
I'll check it out on my next project although I don't see how you would check for the existence of an element?
Buddy
Buddy2y ago
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.
TripleTom
TripleTom2y ago
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.
Buddy
Buddy2y ago
Only one way to test it. BenchmarkDotNet.
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server