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

Length of array #363

Closed
dgorkovets opened this issue Apr 24, 2017 · 3 comments
Closed

Length of array #363

dgorkovets opened this issue Apr 24, 2017 · 3 comments

Comments

@dgorkovets
Copy link

Is it possible to get length of array?

Source:

{
    "key": ["A", "B", "C"]
}

Target:

{
    "keyLength": 3
}
@milosimpson
Copy link
Contributor

Yes, but only on latest version of Jolt (that does not yet power the demo site).

[
  {
    "operation": "modify-overwrite-beta",
    "spec": {
      "keyLength": "=size(@(1,key))"
    }
  }
]

See

public static final class size extends Function.BaseFunction<Integer> {

and
STOCK_FUNCTIONS.put( "size", new Objects.size() );

The infrastructure that powers the Demo Site (Google App Engine) does not like Java 1.8, which I finally updated Jolt to. So will need to figure out a different hosting provider.

@dgorkovets
Copy link
Author

Thanks!

@Dinesh-Rajput
Copy link

Thanks! Very Helpful

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

3 participants