Skip to content

incorrect result when $map($, $append(?)) #86

Closed

Description

@sergeevik

write to simpe test close to my code

  @Test
  public void testTransform() throws IOException {
    Object answer = Json.parseJson("{\"systems\": \"asd2\"}");
    var expression = Jsonata.jsonata("{'systems': 'asd2'}.$map($, $append(?))");
    Object evaluate = expression.evaluate(null);
    Assertions.assertEquals(answer, evaluate);
  }

  @Test
  public void testTransform2() {
    Object answer = Json.parseJson("{\"systems\": \"asd\"}");
    var expression = Jsonata.jsonata("$map($, $append(?))");
    Object evaluate = expression.evaluate(answer);
    Assertions.assertEquals(answer, evaluate);
  }

both failed with error

org.opentest4j.AssertionFailedError: 
Expected :{systems=asd2}
Actual   :[{systems=asd2}, 0]
org.opentest4j.AssertionFailedError: 
Expected :{systems=asd}
Actual   :[{systems=asd}, 0]

https://try.jsonata.org/ return result
first test
Image

second test
Image

Activity

  1. aeberhart commented on Feb 28, 2026

    @aeberhart
    Contributor

    I think the root cause if the we re-use the base function. This explains the test case result which is the same as for this expression: {'systems': 'asd2'}.$map($, $append)

    Image
  2. aeberhart commented on Nov 5, 2026

    @aeberhart
    Contributor

    Fixed on main by #132: as in jsonata-js, only ? leaves a parameter unbound when partially applying a function, so $map($, $append(?)) now returns the expected result. Covered by testMapWithAppend / testMapWithAppend2 in OldPrsTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions