IBM / JSONata4Java

Open Source Java version of JSONata
Apache License 2.0
91 stars 38 forks source link

Problem selecting inside arrays #263

Open dankristensen opened 1 year ago

dankristensen commented 1 year ago

I have created this unit test, that works when using same data on try.jsonata.org. But it currently fails using JSONata4Java

public void shouldEvaluateJsonataExpression() throws Exception {
    ObjectMapper objectMapper = DatabindCodec.mapper();
    JsonNode jsonNode = objectMapper.readTree("[[\"A\",\"B\",\"C\"],[\"AA\",\"BB\",\"CC\"]]");
    Expressions expressions = Expressions.parse("$.[$[0],$[1]]");
    JsonNode evaluatedNode = expressions.evaluate(jsonNode);
    assertThat(evaluatedNode.toString(), equalTo("[[\"A\",\"B\"],[\"AA\",\"BB\"]]"));
}

Any clues on what is wrong

wnm3 commented 1 year ago

I think there is a bug with the $. before the array. Without that we get the same as try.jsonata.org. I'll try to look into this.