Input
[{
\"tags\": [{
\"value\": \"domain:sourcing\"
},
{
Here's another approach. This assumes your tags
array will only contain the names you expect.
map(
reduce (.tags[].value | split(":")) as [$k,$v] (
{domain:"-",apiname:"-"};
.[$k] = $v
)
)
For a more general solution that doesn't assume fixed names and just flattens the tags, I'd do this:
map(
reduce (.tags[].value | split(":")) as [$k,$v] (
del(.tags);
.[$k] = $v
)
)
Then as you access the fields, just use the alternative operator to set the default value.
(.domain // "-") as $domain