Created
July 21, 2020 01:57
-
-
Save MartinGonzalez/8de4bb0474e89ab6179d62eb83019cf4 to your computer and use it in GitHub Desktop.
merge_jsons example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./path/to/example.json => { "name": "Martin", "age": 30 } | |
# ./path/to/example2.json => { "lastName": "Gonzalez", "age": 45, "isDev": true } | |
output_path = "./tmp/merged.json" | |
merged_hash = merge_jsons( | |
jsons_paths: [ | |
"path/to/example.json", | |
"path/to/example2.json" | |
# You can add more here! :O | |
], | |
output_path: output_path # Do you want to save the merge? No problem! | |
) | |
p(merged_hash[:name]) | |
# "Martin" | |
p(merged_hash[:lastName]) | |
# "Gonzalez" | |
p(merged_hash[:age]) | |
# 45 => This value was merged using the last json value. | |
p(merged_hash[:isDev]) | |
# true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment