Skip to content
Advertisement

Tag: jq

How to jq to copy array inside the dictionary?

I have the following json I want to convert it to How do I do this with jq? Answer The solution is the following: In the Command line: See:https://jqplay.org/s/MJ-GoLOBX2 There is more documentation available at: https://programminghistorian.org/en/lessons/json-and-jq#the-dot- Also see the hints below jqplay at the bottom.

jq to remove one of the duplicated objects

I have a json file like this: I tried: but this will remove all the duplicated items, I,m looking to keep just one of the duplicated items, to get the file like this: Answer With field1, I doubt you are getting anything in the output, since there is no key/field with the given name. If you simply change your command

jq array of hashes to csv

So I have a data source like this: I want to get output like this: Using a fake parameter seems like a hack and then needs to be clean up by sed to work. How do I do this with just jq. Answer Instead of trying to put literal newlines in your data, split the data into separate arrays (one

Bash Jq parse json string

I’ve to call a file and pass a json as parameters in this way (suppose that my file is called test.sh), from bash I need to do something like this: and the content of test.sh is the following the output of -> printf “$system_user” is but the output of -> printf “$accounts” is something like this [ [ { “username”:

jq in shellscript: parse argument with ‘-‘

Here’s the json I need to parse: And my code to parse is like the following: The problem is this part: I can’t get the value of it and I guess the reason is that I didn’t pass $var correctly? I also tried But it doesn’t work..Maybe the tiny ‘-‘ in the “config-$val” made it special? So my question is

Advertisement