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 it possible to use if-statement on objects, not values? #98

Open
ChameleonTartu opened this issue May 27, 2022 · 1 comment
Open

Comments

@ChameleonTartu
Copy link
Collaborator

I have an object that I want to decide to use or not to use, based on some fields. Field A as a decision field and Field B as a value field.

Is it possible to do if-statements on objects?

input.json

{
  "companies": [
    {
      "name": "Sillicon Valley",
      "country": "US"
    },
...
    {
      "name": "Tech Hub",
      "county": "Iceland"
    }
  ]
}

output.json

if country == Iceland:

{
  "companies": [
    {
      "name": "Tech Hub"
    }
  ]
}
@thomasborgen
Copy link
Contributor

This is a cool idea @ChameleonTartu

Right now its not possible. You could match a whole object. but not do any if magic based on a values' properties.

Maybe we could add a path keyword to our if_statement that defaults to . for current value.

This could be a really strong feature. Lets think of some more usecases and maybe some implementation ideas.

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