-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Issue with TRecord serialization and skipped empty string, false booleans and empty arrays #110
Comments
…ptions. Addresses the issue #110. I really want to find a better solution for the general problem (serialization options/tweaks) but this may be used as a temporary workaround by those affected by the breaking change I introduced with the new serialization mechanism.
Hi @larsenbjorn , thanks for the kind words and for pointing out this issue. DefaultMARSJSONSerializationOptions.SkipEmptyValues := False; And MARS will serialize empty values to JSON. Let me know your thoughts about this, please. Sincerely, |
Hi, Thank you for such quick reply and workaround! We will be able to utilize this workaround as a temporary solution for now as we have not utilized the OpenAPI feature yet. Changing the options to DefaultMARSJSONSerializationOptions.SkipEmptyValues := False will create an abnormality with the OpenAPI feature. Since DefaultMARSJSONSerializationOptions is a global variable, I guess changing this per resource/endpoint will give funny results for concurrent requests :-) A future solution will maybe allow for separate serialization options for each method (endpoint)? Best regards, |
For sure I am going to let the serialization options to be specified on many levels (Writer, Method, data type definition). In general, I never wanted to write a persistence layer into MARS because I knew there would be many corner cases and little tricky things. But at the same time at some point I needed it so here we come. Stay tuned, I'll try to work on this ASAP. Sincerely, |
In procedure MARS.Core.JSON.pas - TJSONObjectHelper.WriteTValue some fields are skipped if the value is empty. I see that this is beneficial in some cases, but also problematic in other cases.
We use records that are serialized in combination with PUT/PATCH requests. Now we can't know if a string field is supposed to be cleared or not, if a boolean field is supposed to be set to false or not and so on.
I think we need a way to control if serialization should skip these fields or not.
Thank you for your effort. Really like your work with support for OpenAPI 3.
The text was updated successfully, but these errors were encountered: