sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
691 stars 95 forks source link

Possible to have stopPaths not be relative to the data root? #65

Open danielcrk opened 4 years ago

danielcrk commented 4 years ago

I love the stopPaths feature, however, in a structure that looks something like this:

{
  "foo": [
    {
      "bar": {
        "baz": {...}
      }
    }
  ] 
}

... where I want baz to remain uncamelized, it's kinda unusable, as far as I understand.

Would it be possible to do something like stopPaths: ['*.bar.baz']? Does that make sense?

sindresorhus commented 4 years ago

I'm open to supporting this use-case, but the syntax has to be well thought through.

I still think the path should be absolute. Just matching from the end feels a bit loose.

How about something like '*.[].bar.baz', where * means any property and [] means it's an array?

aspirisen commented 3 years ago

I have faced the same issue, do you know what is current approach with arrays for stopPath?

SafNaaz commented 2 years ago

@aspirisen currently arrayname.property works. no need of []

eg, I wanted to stop elements under 'c' getting conveted in a: [ { b : 'x' , c : { d : 'e' } } ]

for that stopPaths:['a.c'] worked.