You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that there is something weird happening when applying a grouping after a filter. An example can be found in the test below:
@Test
void testBrokenPredicate() throws Exception {
JSONObject json = new JSONObject("{\"vendor\":[{\"name\":\"kwik\",\"number\":1},{\"name\":\"kwek\",\"number\":2},{\"name\":\"kwak\",\"number\":3},{\"name\":\"kwak\",\"number\":4}]}");
@Nonnull final JsonNode jsonObj;
try {
jsonObj = new ObjectMapper().readTree(json.toString());
} catch (IOException e) {
throw new APIException(e, "JSONata failed during reading of json");
}
Expressions jsonataExpression = Expressions.parse("vendor[name=\"kwak\"]{`name`: `number`}");
Expressions brokenJsonataExpression = Expressions.parse("vendor[name=\"kwek\"]{`name`: `number`}");
JsonNode result = jsonataExpression.evaluate(jsonObj);
JsonNode brokenResult = brokenJsonataExpression.evaluate(jsonObj);
// The brokenResult does not apply the grouping as expected
JSONAssert.assertEquals("{\"kwak\":[3,4]}", result.toString(), true);
// Here we can see the actual result
JSONAssert.assertEquals("{\"kwek\":{\"number\":2,\"name\":\"kwek\"}}", brokenResult.toString(), true);
// I expect this to succeed as seen here https://try.jsonata.org/ZkhsVPArq, but it fails
JSONAssert.assertEquals("{\"kwek\":2}", brokenResult.toString(), true);
}
Please let me know what I'm doing wrong or if this is a known issue.
The text was updated successfully, but these errors were encountered:
Apologies in advance if overlooking something obvious - I am not well versed in JSONata
I'm trying to reproduce this case with the library: https://try.jsonata.org/ZkhsVPArq
It seems that there is something weird happening when applying a grouping after a filter. An example can be found in the test below:
Please let me know what I'm doing wrong or if this is a known issue.
The text was updated successfully, but these errors were encountered: