Write a function that takes a nested JSON object and flattens it into a single-level key-value pair structure.