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

custom function like math.random() #35

Open
MaciejHadam opened this issue Feb 23, 2024 · 1 comment
Open

custom function like math.random() #35

MaciejHadam opened this issue Feb 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@MaciejHadam
Copy link

In jsonata.js there is possibility to create binding to js namspace and then call a function. For example You can bind Math namespace and call round function.

$math().round(2.5)

How I can do the same binding in dashjoin jsonata implementation?

@aeberhart
Copy link
Contributor

aeberhart commented Feb 23, 2024

The Java equivalent of this would be binding a class in com.dashjoin.jsonata.Jsonata.Frame.bind(String, JFunction) and then calling a method using reflection.

At the moment this is not possible and you have to register the methods individually as described here:
https://github.com/dashjoin/jsonata-java?tab=readme-ov-file#custom-functions

$math.$round(44)
$math binds to java.lang.Math and $round calls https://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#round(double)

Thanks for raising this.

@aeberhart aeberhart added the enhancement New feature or request label Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants