kaiba-tech / kaiba

Kaiba is No-Code Configurable JSON data transformation
https://app.kaiba.tech
MIT License
13 stars 2 forks source link

Is it possible to use if-statement on objects, not values? #98

Open ChameleonTartu opened 2 years ago

ChameleonTartu commented 2 years ago

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 commented 2 years ago

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.