Replies: 2 comments 4 replies
-
.... you have a completely flat data model? That seems unusual. If you instead split the model up into multiple domain types your deserialized size could be smaller than a flatter model due to nested properties not being deserialized in some cases.
You're retaining the JSON structure. There's a break-even point, sure, but it's probably around 25-50% of the fields being filled. If your data is consistently mostly filled you're losing just due to object references. If they're consistently mostly empty your data model is likely too sparse. Note that this only applies if you're receiving lots of instances of models in a relatively short period of time, like for a web api. If these are config values in a client application, the savings are mostly irrelevant.
The answer would be an internal implementation detail, and not something you should rely on. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The docs of
JsonSerializer
seems not detail how it works. Consider the follow:Maybe you will ask, why not deserialize into
Model
directly instead ofJsonNode
?Because in a real environment, a json object may have dozens or even hundreds of fields, but not all of these fields appear at the same time. To define all fields as properties (rather than
get
accessors) in theModel
is an unnecessary waste of memory.Beta Was this translation helpful? Give feedback.
All reactions