All Questions
90
questions
2
votes
4
answers
95
views
Merge json objects into one
I'm trying to merge some json objects using jq.
It seems too complicated for me ^^
I have a JSON which looks like this
[
{
"name": "test_name",
"cpu": "1&...
0
votes
2
answers
415
views
JQ: How to select only some elements in multi-level nested JSON
This is a bit long, but I am at a loss how to glue together multiple jq queries to filter out nested objects in a multi-level structure.
I am starting with JSON that looks like this.
{
"image&...
0
votes
3
answers
249
views
Map array of objects to object of key value pairs
I have the following JSON structure:
[
{
"key11": "value11",
"key12": "value12",
"key13": "value13",
"key14": "...
2
votes
2
answers
61
views
How can I convert an array of strings to an object using jq?
If I have an array such as this one:
[
[
"AppA",
"ServiceA",
"SecretKey",
"topSecretKeyA"
],
[
"AppB",
"ServiceB&...
0
votes
1
answer
303
views
jq: select top two level of the object [duplicate]
I have some json data that looks like:
{
"a1": {
"b1": {
"c1": {...},
"c2": [...]
},
"b2": {
...
0
votes
1
answer
69
views
Collapse distinct JSON objects into one with jq
I have a set of JSON objects that each contain one unique key:value pair (that is, there are no duplicate keys). I want to combine all of these into a single object using jq.
I want this:
{
"...
0
votes
1
answer
41
views
Shell: Map all keys in a string format (json compatible)
I have an object in a file like:
foo.txt
{
"methods" :
{
0 : "GET",
},
}
I would like to convert to json with jq or some other shell converter. Specifically I ...
0
votes
1
answer
316
views
how to create a JSON object from a TSV file containing key/value pairs with jq
I a have a short TSV stream that outputs key/value pairs and I would like to create a JSON object out of it, with jq.
For now I have this code, which generates a stack of JSON objects:
printf '%s\t%s\...
0
votes
1
answer
102
views
JQ: Merge all entries in an array without hardcoding the key
I have a json like this
[
{
"name": "hosts",
"ipaddress": "1.2.3.4",
"status": "UP",
"randomkey": &...
2
votes
1
answer
764
views
Add json object into another json object using bash/jq
I am trying to create a new file adding the object defined in country1.json into world.json. Essentially:
world.json
{
"class": "world",
"version": "1.1.0&...
0
votes
4
answers
388
views
How to limit properties of a JSON object given array of property names using JQ?
Assuming I have the following JSON object (which is just an example):
{
"foo": 1,
"bar": 2,
"baz": 3
}
And the following JSON array (another example):
["...
0
votes
1
answer
541
views
Transform specific fields into array(s) using jq
Given the following JSON:
{
"one": "1",
"two": "2",
"flag": "f1 f2 f3",
"test one": "",
"test two": &...
1
vote
1
answer
158
views
Merge n input objects in jq
I have two JSON input files that I want to merge recursively:
file1.json
{
"key1": {
"key1.1": "foo",
"key1.2": "bar"
},
"key2"...
0
votes
1
answer
198
views
JQ move(or copy) key value pairs to another object if a key/value pair meets condition in that object
I have two files, they are very large so I will give a snippet of relevant data:
from_file:
[
{
"id": 7212486534162308,
"rowNumber": 283,
"cells": ...
0
votes
3
answers
114
views
Merging filter-generated output with static JSON object using jq
I'm trying to use jq to iterate over some delimited text files, and generate objects from the rows.
I also want to add some "static" objects (json shell variable in the example below) to the ...