Quantcast
Channel: Active questions tagged jq - Stack Overflow
Browsing all 520 articles
Browse latest View live

How to merge arrays within JSON object

Given a JSON object{"foo":["barfoo"],"bar":["foobar"]}I would like to merge both arrays, i.e. output:barfoofoobarObviously I can list either array using, e.g. jq -r .foo[] but I'm not sure how to go...

View Article


Conditional if/then/else for JMESPath?

Am trying to do a simple if/then/else using JMESPathFor example: 'if the input is a string, return the string, else return the "value" property of the input'. An input of "abc" would return "abc". An...

View Article


JQ fuction to convert ipv6 address to num and num to addr

I have below python code, which works for converting ipv6 address to number and number to addressdef ipv6_to_number(ipv6): # Split the IPv6 address into segments parts = ipv6.split(':') # Expand the...

View Article

JQ function to convert ipv6 address to num and num to addr [closed]

I have below python code, which works for converting ipv6 address to number and number to addressdef ipv6_to_number(ipv6): # Split the IPv6 address into segments parts = ipv6.split(':') # Expand the...

View Article

How to add consecutive numbers of messages in jq command

I couldn't figure out how to do this, so I asked here.[ {"message" : "This is","Identity" : "1" }, {"message" : " a car","Identity" : "2" }, {"message" : "My Job","Identity" : "11" }, {"message" : "Is...

View Article


How to merge multiple json files in a directory with jq or any tool?

I am trying to merge all json files in a directory (can be many).I know that if there are only 2 files, I can use jq -s . file1.json file2.json. But when I tried to use the a wild card like jq -s ....

View Article

Looks like jq pipe ignores commas and parenthesis

I'm trying to understand the behavior of jq pipes when using parentheses and commas. Let's consider this JSON example:{"menu": [ {"id": "file","value": "File","menuitem": [ {"value": "New","onclick":...

View Article

Print data for an object based on value(variable) for a key in jq output...

I have this JSON :[ {"id": "1","agent": "23ef","displayName": "foo.com" }, {"id": "2","agent": "23gh","displayName": "foo2.com" }, {"id": "3","agent": "23gf","displayName": "boo.com" }]Wanted to get...

View Article


Get outputs from jq on a single line

I got below output using: https://stackoverflow.com/a/40330344 (.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress})Output: { "key": "SEA-739","status":...

View Article


how to use jq to get value from key value dictionary in JSON

I need to get the username and email address for each user in the JSON below.The tricky thing is that each property of the user is stored in a dictionary of name value pairs. The number of name-value...

View Article

Extract dictionaries from JSON where a field value starts with a certain string

I'm trying to parse this json so that I can extract all dictionaries from the input where the "uri" field does not start with the string "/themes" {"version": 0,"permissionMask": 2,"creationDate":...

View Article

jq parse json with key which has special character DOT (.)

I have a json{ "fundingMoved": {"com.mytest.map": {"map": {"java.util.HashMap": {"AGREEMENT_OWNING_ORG": "ABC 22","WAREHOUSE": "XYZ 6" } } } }}I am trying to write a script to see if...

View Article

How to use jq when the variable has reserved characters?

I'm trying to get the following to work and it's not, help me please:curl -s 'https://cryptofresh.com/api/asset/markets?asset=MKR' | jq .OPEN.BTCThe variable in question includes a period, I tried just...

View Article


jq to replace text directly on file (like sed -i)

I have a json file that needs to be updated on a certain condition. Sample json{"Actions" : [ {"value" : "1","properties" : {"name" : "abc","age" : "2","other ": "test1" } }, {"value" :...

View Article

How to pad numbers with JQ?

I'd like to add leading/trailing zeros to strings from numbers — resultant string needs to contain "01" or "001" and not "1". I noticed project https://github.com/joelpurra/jq-zeros but I have jq...

View Article


jq select condition with nested field

I have the following json string below which I would like to select the proxied field.I've used:.result[] | select(.proxied=="false") but that results in "no output"It seems to be how the field proxied...

View Article

manipulate php config file

What's the correct way to automate manipulation of a php config file of this format?sample.php:<?phpreturn ['someobject' => ['somefield' => 'somevalue' ]];I was thinking of converting it to...

View Article


Add new element to existing JSON array with jq

I want to append an element to an array in a JSON file using the jq``add command, but it's not working. report-2017-01-07.json file:{ "report": "1.0","data": { "date": "2010-01-07","messages": [ {...

View Article

Delete all where DOES NOT contain

I have this JSON file json1.json:{"a":"val1","b":"val2","nest1": {"z": "x","test": "containval" }}I need to get a new json where elements whose values that contain val are removed, ANY property can...

View Article

How to append object into a list of objects (not array) using bash

To a list of objects [{..},{..}], I want to add a new object using bash.Example of my list:[ {"name" : "server","image" : "server:latest","essential" : true,"environment" : concat( [ {"name" :...

View Article
Browsing all 520 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>