Click here to Skip to main content
14,599,610 members
Rate this:
Please Sign up or sign in to vote.
See more:
I need a script that can combine multiple JSON files (each file contains one large object) into a separate document containing a single array of all objects from each of the original documents.

What I have tried:

I need a script that can combine multiple JSON files (each file contains one large object) into a separate document containing a single array of all objects from each of the original documents.
Posted
Updated 6-Apr-17 8:28am
v3
Comments
[no name] 6-Apr-17 9:30am
   
We aren't a write-code-to-order service.
Richard Deeming 6-Apr-17 13:08pm
   
So go ahead and write one. You have our permission.

And stop "bumping" your not-a-question up the list. It's extremely rude, and will only end up getting you kicked off the site for abuse.
ZurdoDev 6-Apr-17 14:17pm
   
Do you have a specific question?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You should try the jq tools (jq-json-processor) in shell script to parse json.

Github repository found here
[^]

Online Tool found here
[^]

You need something along the lines of:

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


which will recursively merge two files into one.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100