C
C#2y ago
reeeeeee

❔ Optimize Serializing of the List

Currently I do it like this, but is very slow. var json = JsonConvert.SerializeObject(allUsers, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); The List allUsers is a list of UserPrincipal and have around 1000 elements. The serialization takes are 90 seconds, which I think its a bit too much for a list like that. Is there any way I can optimize that?
5 Replies
ero
ero2y ago
that's insanely unreasonable. is that class nested a lot?
Jester
Jester2y ago
you should maybe make your own user class with less data, that one looks like it does a lot more than just contain a bit info about a user i dont think the serialization is slow, but getting all the properties is, bcuz they might be doing more than just return a value
reeeeeee
reeeeeeeOP2y ago
yeah looks like this is the problem.. I created an empty list of dict<string,string>, and then add each property name:value to it, and it took 90 seconds to create that list as well..
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