[ardoJSON] Ignore empty fields

[ardoJSON] Ignore empty fields

Forge Component
Published on 2 May by Ricardo Silva
22 votes
Published on 2 May by Ricardo Silva
Hi there Ricardo.. Great component by the way.

I'm wondering if it's possible to ignore some fields if not filled in.. Example below:
On this structure 

is it possible to ignore fields serviceid and triggerid

Having this Json 
instead of 


Hello João,

Thank you so much for the feedback on ardoJSON.

While not a difficult problem, I don't see any simple solution that would allow people to declare certain fields as optional. Since I want to maintain ardoJSON as simple as possible, I will refrain from implementing a mechanism which allows you to do this (like the [in my opinion] awful configuration structure in XML Records).

My suggestion for this use-case is for you to implement your own serialization procedure. You can do this in the OutSystems Platform in a Service Studio action, or in an extension with a specific structure and a serialization method for that structure (you can base your code on the ardoJSON code, since it is completely free).

Note that there is no problem with deserialization of values which exist in the structure and not in the JSON.

I may revisit my stance on this if there is sufficient demand for such a mechanism.

Best regards,
Ricardo Silva
Hi Ricardo,

It would be great this mechanism and today I've found a situation where it's mandatory.

For example, using Google Calendar API, Google uses the following structure to manage dates:

- date - if it's an all day event
- datetime 
- timezone

Date and datetime do different things and, most of the time, you only use datetime. But, if you add on your Outsystems structure the date and it goes empty, Google will give an error (which I think it's dumb!) saying it's an invalid date. But sometimes you need to use date instead of datetime.

I think that, at least, for string, it would be great to check that if it's empty, doesn't show up on the JSON (or it would be an input parameter to decide the behaviour).

If you keep your point of view, I will try to figure it out myself.