Omit empty lists in the json representation of `Expression`
Clarification and motivation
With the introduction of TZIP-16, contracts now have an associated metadata, represented as JSON. This metadata can be stored in a contract's storage.
Therefore, it's important that this metadata JSON be as compact as possible, to save on storage costs.
This metadata may contain multiple Micheline expressions and, currently, the ToJSON
instance for Expression
outputs empty json arrays for the "annots"
and "args"
fields, which can quickly add up to a lot of bloat.
We should change the ToJSON
instances to omit empty lists.
I think the FromJSON
instances already consider "annots"
and "args"
optional, so that's probably fine.
If we find that other Expression
fields are also option, we should make sure they're omitted too.
Acceptance criteria
Encoding Micheline expressions without annotations or args (e.g. toExpression (toVal @Integer 1)
) produces a JSON object with no "annots" or "args" fields.