#C487. Merge Two Dictionaries
Merge Two Dictionaries
Merge Two Dictionaries
You are given two dictionaries in JSON format. Your task is to merge these two dictionaries into one. The merged dictionary should contain all key-value pairs from both dictionaries. In the event of a key conflict, the value from the second dictionary should overwrite the value from the first dictionary. Note that the merge is not recursive: if the value for a key is itself a dictionary, then the value from the second dictionary will replace the entire dictionary from the first.
Example: merging {"a": 1, "b": 2}
with {"b": 3, "c": 4}
should yield {"a": 1, "b": 3, "c": 4}
.
inputFormat
The input consists of two lines. Each line is a valid JSON object representing a dictionary. The first line corresponds to the first dictionary and the second line corresponds to the second dictionary.
outputFormat
Output a single line containing the merged dictionary in JSON format. The resulting JSON object should have all key-value pairs from both input dictionaries, with values from the second dictionary taking precedence in case of duplicates.
## sample{"a": 1, "b": 2}
{"c": 3, "d": 4}
{"a":1,"b":2,"c":3,"d":4}