I would like in JQ to substitute the values in the first array with the names in the second array based on the key "size" while keeping the length of the first array unchanged.
[
[{\"size\":0},{\"size\":1},{\"size\":2},{\"size\":3},{\"size\":4},{\"size\":5},{\"size\":6},{\"size\":7},{\"size\":8},{\"size\":9},{\"size\":0},{\"size\":1},{\"size\":2},{\"size\":3},{\"size\":4},{\"size\":5},{\"size\":6},{\"size\":7},{\"size\":8},{\"size\":0},{\"size\":1},{\"size\":2},{\"size\":3},{\"size\":4},{\"size\":5},{\"size\":6},{\"size\":7},{\"size\":8}]
[{\"size\":0,\"name\":\"6M\"},{\"size\":1,\"name\":\"6.5M\"},{\"size\":2,\"name\":\"7M\"},{\"size\":3,\"name\":\"7.5M\"},{\"size\":4,\"name\":\"8M\"},{\"size\":5,\"name\":\"8.5M\"},{\"size\":6,\"name\":\"9M\"},{\"size\":7,\"name\":\"9.5M\"},{\"size\":8,\"name\":\"10M\"},{\"size\":9,\"name\":\"11M\"}]
]
So the wanted result would look like this:
[{\"size\":6M},{\"size\":6.5M},{\"size\":7M},{\"size\":7.5M},{\"size\":8M},{\"size\":8.5M},{\"size\":9M},{\"size\":9.5M},{\"size\":10M},{\"size\":11M},{\"size\":6M},{\"size\":6.5M},{\"size\":7M},{\"size\":7.5M},{\"size\":8M},{\"size\":8.5M},{\"size\":9M},{\"size\":9.5M},{\"size\":10M},{\"size\":6M},{\"size\":6.5M},{\"size\":7M},{\"size\":7.5M},{\"size\":8M},{\"size\":8.5M},{\"size\":9M},{\"size\":9.5M},{\"size\":10M}]
I used this input to obtain the above arrays jq "[ .DATA.product.traits|([.colors.colorMap[]| {size:.sizes[]}]), ( [ .sizes.sizeMap[]| {size:.id, name}])]" and then tried using if-then-else statement (|if (.[0:-1][][].size == .[-1][].size) then [.[-1][].name ] else null end") but I was unable to reach the desired output..