-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialiser_Engine: Improve size of JSON by excluding empty IBHoMObject properties #3144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code doesn't cover the case for the IEnumerable
properties (i.e. Tags
, Fragments
, And CustomData
) as they will show in json even if empty:
In this case, I wonder if it wouldn't be simpler to use a switch-case on prop.Name
to explicitly list the properties to treat differently (simpler and more transparent) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now works as expected.
Happy with the state of the code.
@FraserGreenroyd to confirm, the following actions are now queued:
There are 2 requests in the queue ahead of you. |
The check |
The check |
@BHoMBot check installer |
@FraserGreenroyd to confirm, the following actions are now queued:
|
@BHoMBot this is a DevOps instruction. I am requesting neutral checks on: versioning, unit-tests, installer, ready-to-merge |
@FraserGreenroyd I have provided neutral checks to the checks requested. These checks will need to be run properly to obtain full results. |
Fixes #3017
Test file available here.
Test file is very simple - serialise any object implementing
IBHoMObject
(should be most - I went with an Environment oM Panel) without providing a Name or other property implemented fromIBHoMObject
- see that the JSON doesn't contain the key value pair for those properties. Then provide values to those properties and see them get included.I opted to go with storing the property names on load so that if you're serialising a collection of
IBHoMObjects
, we don't lose time querying the same 5 property names over and over again. Also opted to query theIBHoMObject
properties so that if we ever change them, we don't have to remember to update the list here.I did consider the option of whether we would want to include empty properties if they were overridden (as @IsakNaslundBh has occasionally done to override the
Name
property so he can add his own description to it for certain Structural objects), but decided against it for now on the basis that this will only exclude them if they're empty - so even if they're overridden, if they have no value assigned, do we really want them taking up space in the JSON string? I'm arguing for not - but we could go the other way if there's strong argument to.