jq

generate JSON out of command line arguments

扶醉桌前 提交于 2021-02-09 17:51:22
问题 I want to create JSON output with jq that looks like this: { "records": [ { "id": "1234", "song": "Yesterday", "artist": "The Beatles" } ] } I assumed I have to twiddle with the "filter" of jq whose concept I don't fully get after reading the doc. This is what I got so far: $ jq --arg id 1234 \ --arg song Yesterday \ --arg artist "The Beatles" \ '.' \ <<<'{ "records" : [{ "id":"$id", "song":"$song", "artist":"$artist" }] }' which prints { "records": [ { "id" : "$id", "song" : "$song", "artist

generate JSON out of command line arguments

有些话、适合烂在心里 提交于 2021-02-09 17:51:16
问题 I want to create JSON output with jq that looks like this: { "records": [ { "id": "1234", "song": "Yesterday", "artist": "The Beatles" } ] } I assumed I have to twiddle with the "filter" of jq whose concept I don't fully get after reading the doc. This is what I got so far: $ jq --arg id 1234 \ --arg song Yesterday \ --arg artist "The Beatles" \ '.' \ <<<'{ "records" : [{ "id":"$id", "song":"$song", "artist":"$artist" }] }' which prints { "records": [ { "id" : "$id", "song" : "$song", "artist

generate JSON out of command line arguments

亡梦爱人 提交于 2021-02-09 17:50:38
问题 I want to create JSON output with jq that looks like this: { "records": [ { "id": "1234", "song": "Yesterday", "artist": "The Beatles" } ] } I assumed I have to twiddle with the "filter" of jq whose concept I don't fully get after reading the doc. This is what I got so far: $ jq --arg id 1234 \ --arg song Yesterday \ --arg artist "The Beatles" \ '.' \ <<<'{ "records" : [{ "id":"$id", "song":"$song", "artist":"$artist" }] }' which prints { "records": [ { "id" : "$id", "song" : "$song", "artist

generate JSON out of command line arguments

泄露秘密 提交于 2021-02-09 17:49:24
问题 I want to create JSON output with jq that looks like this: { "records": [ { "id": "1234", "song": "Yesterday", "artist": "The Beatles" } ] } I assumed I have to twiddle with the "filter" of jq whose concept I don't fully get after reading the doc. This is what I got so far: $ jq --arg id 1234 \ --arg song Yesterday \ --arg artist "The Beatles" \ '.' \ <<<'{ "records" : [{ "id":"$id", "song":"$song", "artist":"$artist" }] }' which prints { "records": [ { "id" : "$id", "song" : "$song", "artist

generate JSON out of command line arguments

余生颓废 提交于 2021-02-09 17:47:53
问题 I want to create JSON output with jq that looks like this: { "records": [ { "id": "1234", "song": "Yesterday", "artist": "The Beatles" } ] } I assumed I have to twiddle with the "filter" of jq whose concept I don't fully get after reading the doc. This is what I got so far: $ jq --arg id 1234 \ --arg song Yesterday \ --arg artist "The Beatles" \ '.' \ <<<'{ "records" : [{ "id":"$id", "song":"$song", "artist":"$artist" }] }' which prints { "records": [ { "id" : "$id", "song" : "$song", "artist

基于cropper.js的图片上传和裁剪

♀尐吖头ヾ 提交于 2021-02-08 21:38:05
项目中要求图片上传并裁剪的功能,之前也有接触过很多图片裁剪插件,效果体验不是很好,今天推荐一款好用的插件-cropper,超级好用,裁剪功能丰富,满足了各种需求。 功能: 1:点击选择图片,弹出文件夹选择桌面 文件 2:选择文件之后,打开编辑图片的页面,开始裁剪图片 插件下载地址: http://www.jq22.com/jquery-info18167 插件描述:croppic图像裁剪将满足您的需求,图像加载效果、展现效果以及裁剪都非常棒,相信看到Demo后一定会喜欢上此插件. 图片.png 图片.png 代码: 1:引入相关的css和js文件,cropper.min.css,ImgCropping.css,cropper.min.js等,文件下载地址: http://www.jq22.com/jquery-info18167 <link rel="stylesheet" href="css/cropper.min.css"> <link rel="stylesheet" href="css/ImgCropping.css"> <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script> <script src="js/cropper.min.js"></script> 2:具体代码如下:前端部分 <

jq: Cannot index array with string “id”

爱⌒轻易说出口 提交于 2021-02-08 09:17:37
问题 My backup.json looks like this: { "andres": [ [ { "id": 1, "email": "password", "username": test1, "password": "email@email.com", "name": "Dummy Account", "address": "123 st road",, "ip_address": "0.0.0.0", "phone": "123-123-1234", }, { "id": 2, "email": "email2@email.com", "username": test2, "password": "password", "name": "Dummy Account", "address": "123 st road",, "ip_address": "0.0.0.0", "phone": "123-123-1234" } ], ] } I'm using the command: jq -r '.andres[] | .id, .email, .username,

Trying to Load A Message Payload from a JSON File in Bash to Send to Slack Channel

故事扮演 提交于 2021-02-08 07:36:42
问题 So I am trying to send a message to a specific slack channel using a secrets.json file to specify the payloads for both messages and the web-hook URL. I am able to post things to the message but it does not load the message as a payload even though the payload variable is set correctly. How can I load message payloads within the curl command I am specifying? Here is the code: richardbarret@1152-MBP  ~/Git/SalesforceCLI/Integration/Slack   master ●  ./automated_messages.sh  ✔  1488  10

How to get the output of jq in single line?

泪湿孤枕 提交于 2021-02-08 05:14:31
问题 I have used jq with aws cli to print the instances . Eg: Retrieve instances list aws ec2 describe-instances --filters "Name=tag:bld_env,Values=test" --output json > all-inst.json Jq to print instances id : jq -r '.Reservations[].Instances[].InstanceId' all-inst.json Output of Jq: i-09e0d805cc i-091a61038 i-07d3022 i-0428ac7c4c i-970dc5c4d99 i-014c4ea i-0ac924df i-031f6 and so on.. I want to print them in a line like this : i-09e0d805cc,i-091a61038,i-07d3022,i-0428ac7c4c,i-970dc5c4d99,i

Get json object that has latest timestamp using jq

我的梦境 提交于 2021-02-08 05:10:54
问题 I have a below json file but I'm struggling to only display the description with the latest createdDate . I tried with > < todateiso8601? now and a few more but I can't get this to work. Would anyone be able to help? JSON: { "items": [ { "createdDate": 1543585940, "id": "awefef", "description": "this is description 1" }, { "createdDate": 1555324487, "id": "hjkvhuk", "description": "this is description 2" }, { "createdDate": 1547034297, "id": "xdfxdfv", "description": "this is description 3" }