Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten starting at a specific level #89

Open
amitrai99 opened this issue Oct 22, 2019 · 0 comments
Open

Flatten starting at a specific level #89

amitrai99 opened this issue Oct 22, 2019 · 0 comments

Comments

@amitrai99
Copy link

amitrai99 commented Oct 22, 2019

Hello,

First thanks for such a great library!

I was wondering if there is a config that will allow me to flatten my JSON file starting at a specific depth instead of always flattening from the root to leaf.

Use case:

Input:

flatten(
  {
    "foo": {
      "bar": {
        "a": 1,
        "b": 2,
        "c": 3
      }
    },
    "amaze": {
      "muppet": "wow",
      "haw": "maw"
    }
  }
);

Output:

{
  "foo": {
    "bar.a": 1,
    "bar.b": 2,
    "bar.c": 3,
  },
  "amaze": {
    "muppet": "wow",
    "haw": "maw"
  }
}

Looking at the current options it seems like this would be the opposite of maxDepth. Maybe a minDepth option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant