google/jsonnet

Optional fields

Closed this issue · 0 comments

It would be good if a computed field name evaluated to null, rather than being a dynamic error, if that field was simply omitted from the object. For example

{
    x: 1,
    [if nighttime then "light_brightness" else null]: 100,
}

Will yield either {x: 1} or {x: 1, light_brightness: 100} depending on whether nighttime is true.