#C14955. Flatten Dictionary

    ID: 44661 Type: Default 1000ms 256MiB

Flatten Dictionary

Flatten Dictionary

You are given a nested dictionary. Your task is to flatten the dictionary so that all keys in nested dictionaries are concatenated using a dot (.) as a separator.

For example, given the dictionary:

{ 'a': 1, 'b': { 'c': 2, 'd': { 'e': 3 } } }

the flattened dictionary is:

{ 'a': 1, 'b.c': 2, 'b.d.e': 3 }

In mathematical notation, if you consider a nested dictionary d, its flattened version f(d) is defined as:

[ f(d) = { (k_1 \oplus \text{'.'} \oplus k_2, v) \mid k_1,k_2 \text{ are keys from nested levels and } v \text{ is the corresponding value} } ]

Note that if a key does not have a nested dictionary as its value, it remains unchanged.

inputFormat

The input is given through standard input as a single line containing a valid JSON object that represents a nested dictionary. The keys are strings and the values are either integers or nested dictionaries.

outputFormat

Output the flattened dictionary as a JSON object on a single line via standard output. The keys of the flattened dictionary are created by concatenating the keys from all nesting levels with a dot (.) as the separator.

## sample
{"a":1,"b":2}
{"a":1,"b":2}