Convert deeply nested JSON into a simple key-value structure.
Each nested object becomes a dotted path such as user.address.city, and array items keep their index so the flattened result stays lossless.