-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
I am reopening this issue after making comments to a closed issue
@rhalff rhalff you mention "it's better to solve it in your own code" but we don't always know the object schema.
Is it possible to implement the following?
const object = {
foo: {
bar: 'one'
},
'foo.bar': 'two',
'some': {
'other.node': {
is: 'three'
}
}
}
let value = dot.pick('some["other.node"].is', object);
// three
let value = dot.pick('some["foo.bar"]', object);
// two
let value = dot.pick('some.foo.bar', object);
// one
This is similar to what I would do in code, and it should cover scenarios where the property has spaces and characters that might be used as alternative separators https://github.com/rhalff/dot-object#using-a-different-separator
This could work interchangeably, even for non-dotted properties:
dot.pick('foo.bar', object) === dot.pick('["foo"]["bar"]', object)
dot.pick('["foo.bar"]', object) === object["foo.bar"]
groenroos
Metadata
Metadata
Assignees
Labels
No labels