Skip to content

Commit 9a6061a

Browse files
committed
fix wildcard handling
JList is initialized with 0 or 1 arguments. The original is this: if (arguments.length === 1) { sequence.push(arguments[0]); } If an argument is passed, it is added. The new code mimics this. The second issue is in the wildard handling. In the list case, arrays need to be flattended. The issue comes from the unnecessary handling of maps. Like scalar types, those simply need to be added to the result
1 parent 8b2e385 commit 9a6061a

File tree

3 files changed

+1
-10
lines changed

3 files changed

+1
-10
lines changed

src/main/java/com/dashjoin/jsonata/Jsonata.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,6 @@ Object evaluateWildcard(Symbol expr, Object input) {
723723
if((value instanceof List)) {
724724
value = flatten(value, null);
725725
results = (List)Functions.append(results, value);
726-
} else if (value instanceof Map) {
727-
// Call recursively do decompose the map
728-
results.addAll((List)evaluateWildcard(expr, value));
729726
} else {
730727
results.add(value);
731728
}

src/main/java/com/dashjoin/jsonata/Utils.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,7 @@ public static List<Object> createSequence(Object el) {
7979
JList<Object> sequence = new JList<>();
8080
sequence.sequence = true;
8181
if (el!=NONE) {
82-
if (el instanceof List && ((List)el).size()==1)
83-
sequence.add(((List)el).get(0));
84-
else
85-
// This case does NOT exist in Javascript! Why?
86-
sequence.add(el);
82+
sequence.add(el);
8783
}
8884
return sequence;
8985
}

src/test/java/com/dashjoin/jsonata/ArrayTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ public void testSortNull() {
4949
Assertions.assertEquals(Arrays.asList(Map.of("x", 2), Map.of("x", 1)), expr.evaluate(null));
5050
}
5151

52-
@Disabled
5352
@Test
5453
public void testWildcard() {
5554
Jsonata expr = jsonata("*");
5655
Assertions.assertEquals(Map.of("x", 1), expr.evaluate(List.of(Map.of("x", 1))));
5756
}
5857

59-
@Disabled
6058
@Test
6159
public void testWildcardFilter() {
6260
Object value1 = Map.of("value", Map.of("Name", "Cell1", "Product", "Product1"));

0 commit comments

Comments
 (0)