Flatten an object to single depth. The flattened key is represented with standard javascript object notation.

flatten({ a: { b: 1 } }) // { "a.b": 1 }
flatten({ a: { b: [1] } }) // { "a.b[0]": 1 }
flatten({ a: { '?': [1] } }) // { 'a["?"][0]': 1 }
  • Type Parameters

    • T

    Parameters

    • obj: Record<string, unknown>
    • Optionaloptions: UniFlattenOptions

    Returns Record<string, T>