Bash jq, how to read a json file where field names are like numbers?

I can’t access the values ​​in the json file. Can be a bug for labels like numerics? Or I wrong to use jq? Can you help me? Below json sample Sorry for my English, txs { "datasets":{ "0": { "0": { "0":11, "1":11,"2":10 }, "1": { "0":73, "1":77, "2":87 }, …., …., "n":{ "0":1027, "1":1025,… Read More Bash jq, how to read a json file where field names are like numbers?

Checking for the presence of an element in the array does not work

Sorry to bother you, but I’ve been figuring it out for two hours. The problem is that my code adds only one element, but does not add other ids, writes "already have" $(function(){ $(".js-compare-add").click(function(){ var item_id = $(this).data(‘id’); if(Cookies.get(‘compare_id_list’)){ var compareListStr = Cookies.get(‘compare_id_list’); var compareListArr = compareListStr ? compareListStr.split(‘,’) : []; if (compareListArr.indexOf(item_id) > -1)… Read More Checking for the presence of an element in the array does not work

jq select based on two conditions within one child object

I have a json file with the following format {"id": "3DFD4GF", "demographic": [{"country": "Spain", "rating": 7},{"country": "Germany", "rating": 2}]} I want to see each line where country is "Canada" and rating is 10 in the same object within the demographic array I tried: jq ‘select((.demographic[].country=="Canada") and .demographic[].rating==10)’ json but this will return lines where inside… Read More jq select based on two conditions within one child object

jq: output structure, shortening array, preserving the other fields in the input

For a JSON file like this: { "mylist": […], "foo": "bar" } with mylist containing many elements, how can I output the same JSON structure, but with only the first N elements in mylist? I was trying to use jq ‘.mylist[:N]’, but this prints the first N elements of mylist without the other fields such… Read More jq: output structure, shortening array, preserving the other fields in the input