Skip to content

JSON: Merge

Merges two JSON objects into a single result. Supports shallow merge (second object overwrites first at the top level) and deep merge (recursively combines nested objects while letting the second object take precedence on conflicts). Accepts either native JSON objects or JSON strings.
Preview

Usage

Use this node when you need to combine two JSON sources, such as layering user overrides over defaults, merging configuration fragments, or consolidating API response sections. Choose shallow merge for simple top-level overwrites, or deep merge to recursively combine nested dictionaries.

Inputs

FieldRequiredTypeDescriptionExample
json1TrueWILDCARDThe base JSON data to merge into. Can be a JSON object or a JSON string that parses to an object.{'default': {'theme': 'light', 'features': {'beta': False}}}
json2TrueWILDCARDThe JSON data applied over json1. Its values take precedence on conflicts. Can be a JSON object or a JSON string that parses to an object.{'override': {'theme': 'dark', 'features': {'beta': True}}}
merge_modeTrueENUMMerge strategy to apply. shallow: top-level keys from json2 overwrite json1. deep: recursively merge nested objects; json2 still takes precedence on conflicts.deep

Outputs

FieldTypeDescriptionExample
merged_dataWILDCARDThe merged JSON object after applying the selected merge strategy.{'theme': 'dark', 'features': {'beta': True}}

Important Notes

  • Order matters: json2 overwrites or augments json1 where keys overlap.
  • Input flexibility: Both json1 and json2 may be JSON objects or JSON strings. Strings are parsed automatically.
  • Type requirements: If either input does not resolve to an object (dictionary), the node returns json2 as-is.
  • Deep merge specifics: Only nested objects (dictionaries) are merged recursively. Arrays and non-object types are overwritten by json2.
  • Shallow merge behavior: Only top-level keys are combined; nested structures are not merged recursively.
  • Parsing fallback: Invalid or empty JSON strings are treated as empty objects during parsing.

Troubleshooting

  • Merged result equals json2: One or both inputs were not objects after parsing. Ensure both are JSON objects (e.g., {}) rather than arrays, numbers, or strings.
  • Nested values not merging: Confirm merge_mode is set to "deep". Shallow mode only merges top-level keys.
  • Arrays not merged as expected: Deep merge does not combine arrays; the array from json2 replaces json1's array for the same key.
  • Invalid JSON string input: If a string fails to parse, it is treated as {}. Validate your JSON strings beforehand to avoid unexpected defaults.
  • Unexpected overwrites: In deep merges, when types conflict (e.g., dict vs string), json2's value replaces json1's. Verify your data types for overlapping keys.