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

Custom delimiter function #65

Open
mxl opened this issue Oct 16, 2017 · 5 comments
Open

Custom delimiter function #65

mxl opened this issue Oct 16, 2017 · 5 comments

Comments

@mxl
Copy link

mxl commented Oct 16, 2017

Proposal

Support passing (string, string) => string function as a delimiter option.

For example, for object:

{
  first: {
    second: "hello"
  }
}

and delimiter:

(left, right) => left + right.charAt(0).toUpperCase() + right.slice(1);

it will produce camel case names:

{
  firstSecond: "hello"
}
@mxl
Copy link
Author

mxl commented Oct 30, 2017

@hughsk WDYT if I'll prepare such PR?

@kristianmandrup
Copy link

I need the camel case option as well. We need this functionality for better customisation of key names than a simple separator!

@kristianmandrup
Copy link

There is a snake case variant here

@kristianmandrup
Copy link

kristianmandrup commented Feb 20, 2018

I complete rewrote flat as flat2

Includes loads of customisation options for custom key generation and transforms to fit any such scenario. Now snakecase and camelCase options come built in as well ;)

@lucas-rudd
Copy link

lucas-rudd commented Jul 11, 2018

@mxl how would you handle the case where the object looks like so?

{
  first: {
    second: "hello",
    fOurth: "foo"
  }
}

Now you have the key-value pair

firstFOurth: "foo"

How will this be unflattened? Or, how will you determine whether or not this is first.fOurth or first.f.ourth?

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

3 participants