Running log of JQ's I write

Running log of JQ's I write

This one is to recalculate the average forex rate from a time series data obtained form Oanda

{"calculated_average": ([.HistoricalPoints[].InterbankRate ]| add/length)} + {Average}

This parses the currency codes from a variable in the currency rate history page

[to_entries[] | select(.key|length == 3) | (.value | {name,code,country_primary})]

Filter an object with key's and values to show only key's that contain the string "id"

[to_entries[] | select(.key | contains("id"))] | from_entries

The above can be written more succinctly as follows:

with_entries(select(.key | contains("id")))

Convert an array of objects with specific keys into a CSV file

["timestamp","source","target","rate"],(.[] | [.time,.source,.target,.rate])|@csv