Skip to content

Instantly share code, notes, and snippets.

@MartinGonzalez
Created July 21, 2020 01:57
Show Gist options
  • Save MartinGonzalez/8de4bb0474e89ab6179d62eb83019cf4 to your computer and use it in GitHub Desktop.
Save MartinGonzalez/8de4bb0474e89ab6179d62eb83019cf4 to your computer and use it in GitHub Desktop.
merge_jsons example
# ./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