jq無法將JSON轉換為csv

我是jq新手,我有一個來自(call:all.2)的JSON文件:

{"code":0, "data": {"date": 1617978312600,"ticker": {"KAVAUSDT": {"vol": "15022.96236047","low": "7.0419","open":"7.8990","high": "8.1997","last": "7.1516","buy": "7.1516","buy_amount":"11.02402741","sell":"7.1699","sell_amount": "37.46319593"},"CFXUSDT": {"vol": "108550.36674746","low": "1.226636","open": "1.267724","high": "1.378400","last": "1.273187","buy": "1.272200","buy_amount": "14.65071234","sell": "1.294900","sell_amount": "84.88000789"},"SUSHIBTC": {"vol": "5644.10352324","low": "0.00024680","open": "0.00024857","high": "0.00026493","last": "0.00025704","buy": "0.00025563","buy_amount": "104.74291100","sell": "0.00025730","sell_amount": "94.16400000"},"SUNUSDT": {"vol": "7058.81491709","low":"37.3431","open":"37.9590","high": "44.0446","last": "40.6945","buy": "40.1001","buy_amount": "25.40000000","sell":"41.0771","sell_amount": "3.40000000"}}}, "message": "OK"}

我想將數據轉換成csv(空格分隔),如下所示:如所附圖像所示

我嘗試了以下方法,但沒有成功:

mlr --j2c cat all.2>allq1.csv

jq -r '.[]|[ .ticker,.ticker.vol,.ticker.low,.ticker.open,.ticker.high,.ticker.last,.ticker.buy,.ticker.buy_amount,.ticker.sell,.ticker.sell_amount ]|@csv' all.2 > all.csv
? 最佳回答:

Try

jq -r '.data.ticker | to_entries[] | [.key, (.value | (.vol|tonumber), (.low|tonumber))] | @csv'

解釋:.data.ticker-數據路徑,to_entries[]-由于ticker name是鍵,我們需要將此對象轉換為.key.value()-括號有幫助,所以您不必每次都寫完整路徑,tonumber-將字符串轉換為數字(刪除雙引號)

添加所有字段

主站蜘蛛池模板: 亚洲无删减国产精品一区| 中文字幕在线无码一区二区三区| 日韩美一区二区三区| 日本一区二区三区中文字幕| 免费播放一区二区三区| 国产激情精品一区二区三区| 国产成人精品一区二区A片带套| 一本大道东京热无码一区| 亚洲高清成人一区二区三区| 国产成人精品视频一区| 国产一区二区三区小说| 精品性影院一区二区三区内射| 手机看片一区二区| 中文字幕无码免费久久9一区9| 亚洲人成网站18禁止一区| 色一乱一伦一区一直爽| 国产在线精品一区二区在线看| 国产精品高清视亚洲一区二区| 亚洲制服丝袜一区二区三区| 亚洲福利一区二区三区| 亚洲视频一区网站| 国产精品第一区揄拍| 亚洲国产系列一区二区三区| 亚洲愉拍一区二区三区| 波多野结衣一区二区| 无码人妻精品一区二区蜜桃 | 波多野结衣的AV一区二区三区| 亚洲国产精品一区二区九九 | 精品人妻少妇一区二区| 成人免费一区二区三区| 久久精品动漫一区二区三区| 日韩精品一区二区亚洲AV观看| 人妻无码第一区二区三区| 亚洲香蕉久久一区二区三区四区| 97se色综合一区二区二区| 天海翼一区二区三区高清视频| 无码毛片一区二区三区中文字幕| 久久成人国产精品一区二区| 国产美女精品一区二区三区| 国产美女在线一区二区三区| 手机福利视频一区二区 |