#C10219. Flatten Nested JSON

    ID: 39400 Type: Default 1000ms 256MiB

Flatten Nested JSON

Flatten Nested JSON

You are given a nested JSON object. Your task is to flatten this JSON so that every key in the resulting dictionary corresponds to a path in the original object. Use a dot (.) as the separator between the keys from each level.

For example, if the input JSON is:

{
  "user": {
    "name": "John",
    "address": {
      "city": "New York",
      "zip": "10001"
    }
  },
  "active": true
}

Then your program should output:

{
  "user.name": "John",
  "user.address.city": "New York",
  "user.address.zip": "10001",
  "active": true
}

Note that if a value is a JSON array, it must remain unchanged. All formulas or explanations should use LaTeX format when mathematical notation is needed.

inputFormat

The input is provided via stdin as a single JSON string representing an object. This object may be empty or contain nested objects.

outputFormat

Output a single JSON string to stdout representing the flattened JSON object. Each key in the output is formed by concatenating the keys from the nested structure with a dot (.) as a separator.

## sample
{"user": {"name": "John", "address": {"city": "New York", "zip": "10001"}}, "active": true}
{"user.name":"John","user.address.city":"New York","user.address.zip":"10001","active":true}