Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 602

JQ print two arrays values using the same index

$
0
0

in the following example I have two arrays (timestamp and values) that are related by the same index, so timestamps[0] is related to values[0], timestamps[1] is related to values[1], ...

{"timestamps": ["1730135460000", "1730137620000"], "values" : ["15", "23"]}

I need to print each one in a row like this:

1730135460000 151730137620000 23

But instead I am getting:

1730135460000 1730137620000 15 23

I know this is wrong but wondering if there is a way to achieve what I am looking for

echo '{"timestamps": ["1730135460000", "1730137620000"], "values" : ["1", "2"]}' | jq -r '[ .timestamps[], .values[] ] | @tsv'

Thanks!


Viewing all articles
Browse latest Browse all 602

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>