4 ms·
True, but isn't it a good idea to have an "upper limit" global value too in case of badly behaved types?
by shawnz 6y ago
True, but isn't it a good idea to have an "upper limit" global value too in case of badly behaved types?
- Arnavion 6y agoYes, a limit per type. Not for the whole serialization.
- shawnz 6y agoBut what if a type which you need to serialize wrongly doesn't set the limit? EDIT: I see your point now, thank you for explaining
- Arnavion 6y agoAgain, I'm not saying there shouldn't be a default limit. I'm saying the limit should be per type, not for the whole serialization. It can be something as trivial as "PSHashTable is allowed to serialize without limit. Every other type is limited to N levels, unless the user sets `$SERIALIZATION_LIMIT[System.Type]` to some other value." Or make the `-Depth` parameter a `Dictionary<System.Type, int>`.
- chmod775 6y agoWhy? Both JSON strings and their deserialized value's memory usage grows only linearly if you nest stuff (unless you're doing something dumb). By that logic they should also add -MaxArrayLength to make the parser stop parsing long JSON arrays, -MaxProperties to make it only parse object properties up to a limit, -MaxStringLength to only make it parser strings up to a certain length... It's completely pointless.
- shawnz 6y agoI suppose it is only a concern during serialization, not deserialization.