Hi Bruno,
If you're using Advanced SQL, you can use the ISNULL function to make sure, that you don't get nulls and get the 0.
Something like this:

The is null basically works like if field is not null, it retrieves the first attribute, otherwise the second.
Using this function forces the output of the query not to be null which is what you're trying to do.
Additionally, you can set the attributes of the structure you're deserializing to, to Mandatory so you force them to appear:

Hope it helps.
Regards,
João