extensible jsonnet transformations¶
xtrasonnet is an extensible, jsonnet-based, data transformation engine for Java or any JVM-based language.¶
xtrasonnet is an extension of databricks' sjsonnet, a Scala implementation of Google's jsonnet. xtrasonnet enables extensibility, adds support for data formats other than JSON, and adds data transformation facilities through the xtr
library and some additions to the jsonnet language itself.¶
➡
➡
How extensible?¶
xtrasonnet has two points of extensibility:
- Custom functions: users can write native (e.g.: Java or Scala) functions as a
Library
and utilize them from their transformation code. - Any* data format: users can write a custom
DataFormatPlugin
and transform from/to a given data format.
* Any format that can be expressed as jsonnet elements.
What kind of additions to the jsonnet language?¶
There are two main additions motivated to facilitate data transformation applications:
Null-safe select ?.
¶
This allows developers to select, and chain, properties arbitrarily without testing existence.
local myObj = {
keyA: { first: { second: 'value' } },
keyB: { first: { } }
};
{
a: myObj?.keyA?.first?.second,
b: myObj?.keyB?.first?.second,
c: myObj?.keyC?.first?.second
}
➡
Null coalescing operator ??
¶
This allows developers to tersely test for null
and provide a default value. For example
local myObj = {
keyA: { first: { second: 'value' } },
keyB: { first: { } }
};
{
a: myObj?.keyA?.first?.second,
b: myObj?.keyB?.first?.second ?? 'defaultB',
c: myObj?.keyC?.first?.second ?? 'defaultC'
}
➡