sjsonnet
sjsonnet copied to clipboard
null Safe select operator, aka. Optional_chaining
refs: https://github.com/google/jsonnet/issues/930 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining#optional_chaining_with_expressions
In JSONPath, we can select deeply, even it may be null.
maybeNull: someObject?.innerObject?.whatIWant
I think we can support this with a ?. instead of ..
I have implemented it with :
eval(
"""
|local obj = {a: 1};
|local obj2 = null;
|obj2?.a
|
|""".stripMargin) ==> ujson.Null
or maybe just use std.get
This project is using this syntax https://github.com/jam01/xtrasonnet