-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Sample code for reproducing the error:
package com.example;
import com.api.jsonata4java.expressions.EvaluateException;
import com.api.jsonata4java.expressions.Expressions;
import com.api.jsonata4java.expressions.ParseException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
public class JSONataExample {
public static void main(String[] args) {
String json = """
{
"company": {
"name": "TechCorp",
"departments": {
"IT": { "employees": 50 },
"HR": { "employees": 10 }
}
}
}
""";
final var expression = """
$map($keys($.company.departments), function($k) {
[ $.company.name, $k, $lookup($.company.departments, $k).employees ]
})
""";
final var mapper = new ObjectMapper();
try {
final var input = mapper.readTree(json);
var expr = Expressions.parse(expression);
try {
final var result = expr.evaluate(input);
System.out.println("JSONata result: " + result);
} catch (EvaluateException e) {
System.err.println(e.getLocalizedMessage());
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
}
}
Output:
Argument 2 of function $lookup does not match function signature
Metadata
Metadata
Assignees
Labels
No labels