I have input that looks like this:
{
"INS-2000_loop": [
{
"HD-2300_loop": [
{
"COB-2320_loop": [
{
"COB_01": "11",
"COB_02": "12",
"COB_03": "13"
},
{
"COB_01": "21",
"COB_03": "23"
},
{
"COB_01": "31",
"COB_02": "32"
},
{
"COB_02": "42",
"COB_03": "43"
}
]
}
]
}
]
}
Currently my spec looks like this:
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"HD-2300_loop": {
"*": {
"COB-2320_loop": {
"*": {
"COB_01": "L2320.[&1].x",
"COB_02": "L2320.[&1].y",
"COB_03": "L2320.[&1].z"
}
}
}
}
}
}
}
},
{
"operation": "default",
"spec": {
"L2320": [
{ "x": null, "y": null, "z": null }
]
}
}
]
which gives this result:
{
"L2320": [
{
"x": "11",
"y": "12",
"z": "13"
},
{
"x": "21",
"z": "23"
},
{
"x": "31",
"y": "32"
},
{
"y": "42",
"z": "43"
}
]
}
I would like the result to have null defaults like this:
{
"L2320": [
{
"x": "11",
"y": "12",
"z": "13"
},
{
"x": "21",
"y": null,
"z": "23"
},
{
"x": "31",
"y": "32",
"z": null
},
{
"x": null,
"y": "42",
"z": "43"
}
]
}
There may be any number of elements in the input array (though likely no more than 5 or 6). Is there a way for me to specify default values for the complex element attributes?
2
Answers
Hi spec will help you resolve your query :
First spec is as it is, in 2nd spec use modify-default-beta instead of default operation.
nesting elements within square brackets
*
instead|
instead(similar to an OR operator), for the ones with common values (right hand side expressions)such as