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

Support for Jolt-like "&" and "@" wildcards/operators for shift #88

Open
jeffneely opened this issue Oct 10, 2018 · 1 comment
Open

Comments

@jeffneely
Copy link

jeffneely commented Oct 10, 2018

It doesn't seem like Kazaam supports some of the wildcard functionality that Jolt offers in terms of the shift operation...

As an example, here is a Jolt shift spec:

  {
    "operation": "shift",
    "spec": {
      "job": {
        "task": {
          "*": {
            "query": {
              "*": {
                "name": "tasks[&3].queries[&1].query",
                "enabled": "tasks[&3].queries[&1].query_enabled",
                "@(2,name)": "tasks[&3].queries[&1].task_name",
                "@(4,name)": "tasks[&3].queries[&1].job_name"
              }
            }
          }
        }
      }
    }
 }

Specifically:
"&" - references key values captured by a walked wildcard "*" path to get a value
Example:

{
    "foo" : {
        "bar": {
            "baz":  // &0 = baz, &1 = bar, &2 = foo
        }
    }
}

"@" - reference another key by name in a walked wildcard "*" path
Example: "@(3,title)"
"3" means go up the tree 3 levels and then lookup the key "title" and use the value at that key

Any plans to support these?

@yxuco
Copy link

yxuco commented Nov 6, 2018

Isn't the spec of this package reversed from Jolt? Jolt spec maps from input field to output field path, while kazaam maps output field to input field path. Would this change make it harder to introduce iterative wildcard "*", or to create a new array based on an input array? For example, the following Jolt spec would create a new array photos[] from an input array Photos[]. Can Kazaam do something similar?

	spec := `{
        "Photos": {
            "*": {
                "Id": "photos[&1].id",
                "Caption": "photos[&1].caption",
                "Sizes": {
                    "*": {
                        "Url": "photos[&3].sizes.&1"
                    }
                },
                "SizesOrder": "photos[&1].sizesOrder"
            }
        }
    }`

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