Skip to main content
deleted 147 characters in body
Source Link
0stone0
  • 45.5k
  • 6
  • 53
  • 82

Update

If you're not sure about the number of objectUse 's add, you can usethis will concatenate all the add option;input objects;

// Multiple variables holding objects jq -s add <<< "$j1 $j2 $j3"   //or command |Multiple files holding objects jq -s add file1 file2 file3 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq // -sCommand '.[0]output *with .[1]multiple *columns command .[2]'| file1jq file2-s file3add 

3 VariablesManually

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :You can add multiple columns by hand like so;

jq -s '.[0] * .[1] * .[2]' <<< "$j1file1 $j2file2 $j3"file3 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

Update

If you're not sure about the number of object, you can use the add option;

jq -s add <<< "$j1 $j2 $j3" //or command | jq -s add 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

Use 's add, this will concatenate all the input objects;

// Multiple variables holding objects jq -s add <<< "$j1 $j2 $j3"   // Multiple files holding objects jq -s add file1 file2 file3  // Command output with multiple columns command | jq -s add 

Manually

You can add multiple columns by hand like so;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 
added 156 characters in body
Source Link
0stone0
  • 45.5k
  • 6
  • 53
  • 82

Update

If you're not sure about the number of object, you can use the add option;

jq -s add <<< "$j1 $j2 $j3" //or command | jq -s add 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

Update

If you're not sure about the number of object, you can use the add option;

jq -s add <<< "$j1 $j2 $j3" //or command | jq -s add 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 
added 60 characters in body
Source Link
0stone0
  • 45.5k
  • 6
  • 53
  • 82

3 Files

If your existing json is available from 3 seperate files, you can justuse the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the seperateseparate json is avaiableavailable in 3 variables, create a new onestring, with all thecontaining those 3 objects and let. Use here string to pass the string into concatenate them like above:

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

3 Files

If your existing json is available from 3 seperate files, you can just the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the seperate json is avaiable in 3 variables, create a new one, with all the objects and let concatenate them like above:

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 

3 Files

If your existing json is available from 3 seperate files, you can use the following command to concatenate them;

jq -s '.[0] * .[1] * .[2]' file1 file2 file3 

3 Variables

If the separate json is available in 3 variables, create a new string, containing those 3 objects. Use here string to pass the string into :

jq -s '.[0] * .[1] * .[2]' <<< "$j1 $j2 $j3" 

Result

Both options result in:

{ "Woonkamer": { "currentTemperature": 21.8, "battery": 75, "isFailed": false }, "Hal": { "currentTemperature": 19.5, "battery": 48, "isFailed": false }, "Bijkeuken": { "currentTemperature": 18.4, "battery": 56, "isFailed": false } } 
Source Link
0stone0
  • 45.5k
  • 6
  • 53
  • 82
Loading