Skip to main content
edited tags
Link
peak
  • 119.1k
  • 21
  • 185
  • 218
added 12 characters in body
Source Link
Smile4ever
  • 3.8k
  • 3
  • 29
  • 34

I would like to merge two files containing JSON. They each contain an array of JSON objects.

registration.json

[ { name"name": "User1", registration"registration": "2009-04-18T21:55:40Z" }, { name"name": "User2", registration"registration": "2010-11-17T15:09:43Z" } ] 

useredits.json

[ { "name": "User1", "editcount": 164 }, { "name": "User2", "editcount": 150 }, { "name": "User3", "editcount": 10 } ] 

In the ideal scenario, I would like to have the following as a result of the merge operation:

[ { "name": "User1", "editcount": 164, registration"registration": "2009-04-18T21:55:40Z" }, { "name": "User2", "editcount": 150, registration"registration": "2010-11-17T15:09:43Z" } ] 

I have found https://github.com/stedolan/jq/issues/1247#issuecomment-348817802 but I get

jq: error: module not found: jq 

I would like to merge two files containing JSON. They each contain an array of JSON objects.

registration.json

[ { name: "User1", registration: "2009-04-18T21:55:40Z" }, { name: "User2", registration: "2010-11-17T15:09:43Z" } ] 

useredits.json

[ { "name": "User1", "editcount": 164 }, { "name": "User2", "editcount": 150 }, { "name": "User3", "editcount": 10 } ] 

In the ideal scenario, I would like to have the following as a result of the merge operation:

[ { "name": "User1", "editcount": 164, registration: "2009-04-18T21:55:40Z" }, { "name": "User2", "editcount": 150, registration: "2010-11-17T15:09:43Z" } ] 

I have found https://github.com/stedolan/jq/issues/1247#issuecomment-348817802 but I get

jq: error: module not found: jq 

I would like to merge two files containing JSON. They each contain an array of JSON objects.

registration.json

[ { "name": "User1", "registration": "2009-04-18T21:55:40Z" }, { "name": "User2", "registration": "2010-11-17T15:09:43Z" } ] 

useredits.json

[ { "name": "User1", "editcount": 164 }, { "name": "User2", "editcount": 150 }, { "name": "User3", "editcount": 10 } ] 

In the ideal scenario, I would like to have the following as a result of the merge operation:

[ { "name": "User1", "editcount": 164, "registration": "2009-04-18T21:55:40Z" }, { "name": "User2", "editcount": 150, "registration": "2010-11-17T15:09:43Z" } ] 

I have found https://github.com/stedolan/jq/issues/1247#issuecomment-348817802 but I get

jq: error: module not found: jq 
Source Link
Smile4ever
  • 3.8k
  • 3
  • 29
  • 34

How to merge arrays from two files into one array with jq?

I would like to merge two files containing JSON. They each contain an array of JSON objects.

registration.json

[ { name: "User1", registration: "2009-04-18T21:55:40Z" }, { name: "User2", registration: "2010-11-17T15:09:43Z" } ] 

useredits.json

[ { "name": "User1", "editcount": 164 }, { "name": "User2", "editcount": 150 }, { "name": "User3", "editcount": 10 } ] 

In the ideal scenario, I would like to have the following as a result of the merge operation:

[ { "name": "User1", "editcount": 164, registration: "2009-04-18T21:55:40Z" }, { "name": "User2", "editcount": 150, registration: "2010-11-17T15:09:43Z" } ] 

I have found https://github.com/stedolan/jq/issues/1247#issuecomment-348817802 but I get

jq: error: module not found: jq