jq

jq get each value in array with parent

北慕城南 提交于 2021-01-27 06:45:07
问题 I have json that looks like the below. I'd like to get an output that contains one line for each timer record, but includes the name of the service. { "services":{ "service":[ { "name":"Test Value", "timer":[ { "datetime":"08/30/2017 16:33:35", "value":"625" }, { "datetime":"08/30/2017 16:22:38", "value":"240" } ] }, { "name":"Test Value 2", "timer":[ { "datetime":"08/30/2017 16:07:38", "value":"432" }, { "datetime":"08/30/2017 15:59:07", "value":"1355" } ] } ] } } I've come up with .services

jq get each value in array with parent

我们两清 提交于 2021-01-27 06:43:45
问题 I have json that looks like the below. I'd like to get an output that contains one line for each timer record, but includes the name of the service. { "services":{ "service":[ { "name":"Test Value", "timer":[ { "datetime":"08/30/2017 16:33:35", "value":"625" }, { "datetime":"08/30/2017 16:22:38", "value":"240" } ] }, { "name":"Test Value 2", "timer":[ { "datetime":"08/30/2017 16:07:38", "value":"432" }, { "datetime":"08/30/2017 15:59:07", "value":"1355" } ] } ] } } I've come up with .services

解析MYSQL(二)

允我心安 提交于 2021-01-22 23:33:51
上一篇文章讲的是mysql的基本操作,这一篇会有一点难以理解,本节主要内容mysql视图,存储过程,函数,事务,触发器,以及动态执行sql 视图view 视图是一个虚拟表,其内容由查询定义。同真实的表一样,视图包含一系列带有名称的列和行数据。但是,视图并不在数据库中以存储的数据值集形式存在。行和列数据来自由定义视图的查询所引用的表,并且在引用视图时动态生成。对其中所引用的基础表来说,视图的作用类似于筛选。定义视图的筛选可以来自当前或其它数据库的一个或多个表,或者其它视图。通过视图进行查询没有任何限制,通过它们进行数据修改时的限制也很少。视图是存储在数据库中的查询的SQL 语句,它主要出于两种原因:安全原因, 视图可以隐藏一些数据。 1、创建视图 --格式:CREATE VIEW 视图名称 AS SQL语句 CREATE VIEW v1 AS SELET nid, name FROM tab1 WHERE nid > 4 2、删除视图 --格式:DROP VIEW 视图名称 DROP VIEW v1 3、修改视图 -- 格式:ALTER VIEW 视图名称 AS SQL语句 ALTER VIEW v1 AS SELET A.nid,B. NAME FROM tab1 LEFT JOIN B ON A.id = B.nid LEFT JOIN C ON A.id = C.nid

jq sorts KEY and VALUES in different way - how can I enumerate them in the same order?

China☆狼群 提交于 2021-01-21 04:39:27
问题 I get REST output in JSON format using curl command as below Getting KEY names alone using: curl http://test.te:8080/testApp/app/version | jq '.version' | jq '. | keys' OUTPUT: "Archiver-Version", "Build-Id", "Build-Jdk", "Build-Number", "Build-Tag", "Built-By" Getting VALUES alone using: curl http://test.te.com:8080/testApp/app/version | jq '.version' | jq '.[]' OUTPUT (Note how the order of values doesn't correspond to the order of key names; e.g., the first value, "user@test.com" , is the

Install jq JSON processor on Ubuntu 10.04

大兔子大兔子 提交于 2021-01-20 18:45:28
问题 Is there a way to install jq JSON processor on Ubuntu 10.04? I Tried the usual sudo apt-get install jq but got the error E: Couldn't find package jq 回答1: It is possible to perform sudo apt-get install jq however you need to inform the system where to find jq. ℹ️ Note : Ubuntu 14+ users can skip to step 4! 🎉 Install Open your sources file in a text editor: sudo vim /etc/apt/sources.list Add the following line to the end of that file (note deb is not a command, more info): deb http://us.archive

Install jq JSON processor on Ubuntu 10.04

南楼画角 提交于 2021-01-20 18:45:06
问题 Is there a way to install jq JSON processor on Ubuntu 10.04? I Tried the usual sudo apt-get install jq but got the error E: Couldn't find package jq 回答1: It is possible to perform sudo apt-get install jq however you need to inform the system where to find jq. ℹ️ Note : Ubuntu 14+ users can skip to step 4! 🎉 Install Open your sources file in a text editor: sudo vim /etc/apt/sources.list Add the following line to the end of that file (note deb is not a command, more info): deb http://us.archive

Leave only fields with string values

南笙酒味 提交于 2021-01-20 06:50:29
问题 I have a JSON structure like this: { "1": "a-secret", "A": "b-secret", "2": { "3": "ab-secret", "4": { "5": "adc-secret" }, "6": { "7": "abdc-secret" } } } I am trying to create a command (preferable one liner) to return key pairs that only have string values. So for the above it would return: { "1": "a-secret", "A": "b-secret" } I have found .[]|strings that returns only the string values but I need both the key and value and that's where I'm stumped! 回答1: You are looking for map_values. $

java并发之TimeUnit理解

一笑奈何 提交于 2021-01-18 17:02:29
TimeUnit是java.util.concurrent包下面的一个类,TimeUnit提供了可读性更好的线程暂停操作,通常用来替换Thread.sleep(),在很长一段时间里Thread的sleep()方法作为暂停线程的标准方式,几乎所有Java程序员都熟悉它,事实上sleep方法本身也很常用而且出现在很多面试中。如果你已经使用过Thread.sleep(),当然我确信你这样做过,那么你一定熟知它是一个静态方法,暂停线程时它不会释放锁,该方法会抛出InterrupttedException异常(如果有线程中断了当前线程)。但是我们很多人并没有注意的一个潜在的问题就是它的可读性。Thread.sleep()是一个重载方法,可以接收长整型毫秒和长整型的纳秒参数,这样对程序员造成的一个问题就是很难知道到底当前线程是睡眠了多少秒、分、小时或者天。看看下面这个Thread.sleep()方法: Thread.sleep(2400000) 粗略一看,你能计算出当前线程是等待多长时间吗?可能有些人可以,但是对于大多数程序员来说这种写法的可读性还是很差的,你需要把毫秒转换成秒和分,让我们来看看另外一个例子,这个例子比前面那个例子可读性稍微好一点: Thread.sleep(4*60*1000); 这比前面那个例子已经好多了,但是仍然不是最好的,你注意到睡眠时间用毫秒

【同说】@曼青:前端折腾之路

别说谁变了你拦得住时间么 提交于 2021-01-18 10:34:59
前言 还记得之前的那个 【同说】我的前端路上期待有你! 吗?早读君有做过专访前端界的前辈们,分享他们的经验,那么在我们身边呢其实也存在非常多低调的前端大神,只是有时候我们不知道而已。那么同说计划就是为你设立的。 正文从这开始 @曼青, 广州华农某宿舍,妹子一枚,19岁(读书比较早还在奔二的路上啊哈哈)。曾参加过 【活动】第二期21 天技术书籍阅读分享 在前端摸爬滚打已经两个年头,说长不长说短不短,一直想写点什么记录一下自己的成长,刚好看到早读君的活动,起身动笔。 两年半前,带着想进IT行业想学计算机的想法入了华农的网络工程专业(然后回家都会被人问..呀跑去耕田了么…),稀里糊涂的开始了各种计算机基础理论课。然而一行行的代码,仅仅是在黑白屏之间跳跃,作为一个从小喜欢美术自认为有些艺术细胞的我,实在觉得枯燥对于课程也只是处于好好学习并未深究的阶段。 再说真正接触前端, 从大一的一次网页比赛设计开始,为了响应学校的号召发挥自己多年的设计才能(我才不会说是看中他的奖金呢(咳咳…),设计了一个当时自认为不错的网站然后一两星期在w3cschool上速成了html+css,当然….结果是跟大奖无缘。不过也正是这一次经历,让我发现了原来语言不仅仅是运行在控制台输出结果用了,原来有这么神奇的东西存在,原来我想的我画的东西可以真实的显示在网页中,可以那么酷炫的动起来。接着的剧情可想而知…

/usr/bin/jq: Argument list too long error bash

旧巷老猫 提交于 2021-01-18 06:59:25
问题 I want to replace the value in sample json from larger swagger.json file content and it is too large. Error: /usr/bin/jq: Argument list too long error bash worked to solve this issue for a few days and cannot identify the issue here. this is the sample json file: { "name": "", "description": "", "context": "", "version": "", "provider": "cbs", "apiDefinition": "", "wsdlUri": null, "responseCaching": "Disabled", "cacheTimeout": 300, "destinationStatsEnabled": false, "isDefaultVersion": true,