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

Is there an Elegant way to map Multiple Child keys #3

Open
DheerajKN opened this issue Oct 8, 2019 · 0 comments
Open

Is there an Elegant way to map Multiple Child keys #3

DheerajKN opened this issue Oct 8, 2019 · 0 comments
Assignees

Comments

@DheerajKN
Copy link

I had a small query if there is a better way for including child keys. Like in this case:

const person = {
  name: "John Doe",
  age: 27,
  kids:[
    {
      name: "James Doe",
      age: 7
    },
    {
      name: "Mary Doe",
      age: 7
    }
  ]
}

const JsonPropertyFilter = require("json-property-filter");
 
console.log(new JsonPropertyFilter.JsonPropertyFilter("name", "kids.name", "kids.age").apply(person));

So here I have to write kids. kids. twice to get 2 keys from a child object and it's gonna increase with the requirement of more keys. So is there a better solution like kids[name, age] or kids{name, age} just to remove repetition.

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

No branches or pull requests

2 participants