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

Ability to grab values from outside over context. #109

Open
jmcnevin opened this issue Jun 14, 2021 · 1 comment
Open

Ability to grab values from outside over context. #109

jmcnevin opened this issue Jun 14, 2021 · 1 comment

Comments

@jmcnevin
Copy link

I'm attempting to transform a document like this:

{
  "first_name": "John",
  "last_name": "Doe",
  "children": [{ "first_name": "Jack" }, { "first_name": "Jane" }]
}

Into something like this:

[
  {
    "first_name": "Jack",
    "last_name": "Doe"
  },
  {
    "first_name": "Jane",
    "last_name": "Doe"
  }
]

This would take the children's first names and combine them with the parent's last name. I'm not sure if this can be done currently without some way of escaping the context created by using over, like this (borrowing from syntax I've seen in JSONata):

{
  "operation": "shift",
  "spec": {
    "first_name": "first_name",
    "last_name": "$$.last_name"
  },
  "over": "children"
}

This would be a nice feature to have, unless some other solution is possible.

@JoshuaC215
Copy link
Collaborator

Hey there, yeah I don't know of a good way to do this currently. Agreed that it would be useful. I am not sure how to do a clean implementation of this but would welcome ideas. I think the relevant code section is here, and at first glance it seems like passing around the whole object context in that loop would be clunky - I think it would need to be a new function parameter in all the transforms, or something like that.

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

2 participants