diff --git a/json-logic-java/src/main/java/com/jsonlogic/FilterNode.java b/json-logic-java/src/main/java/com/jsonlogic/FilterNode.java index 735a37e..8c0268a 100644 --- a/json-logic-java/src/main/java/com/jsonlogic/FilterNode.java +++ b/json-logic-java/src/main/java/com/jsonlogic/FilterNode.java @@ -40,29 +40,27 @@ Result eval(Map data) throws EvaluationException{ right.treeToString(sb); - if(sb.toString().contains("{\"var\":\"\"}")) - { - JsonArray results=new JsonArray(); + + JsonArray results=new JsonArray(); - for(int i=0;i t { if(entry.getKey().startsWith(name+".$"+i)) { - String fieldName=entry.getKey().replaceAll("^"+name+"\\.\\$"+i+"\\.",""); + String regName = name.replaceAll("\\$", Matcher.quoteReplacement("\\$")); + + String fieldName=entry.getKey().replaceAll("^"+regName+"\\.\\$"+i+"\\.",""); if(entry.getValue().isString()) jj.addProperty(fieldName,entry.getValue().getStringValue()); @@ -139,6 +142,10 @@ else if(entry.getValue().isDouble()) jj.addProperty(fieldName,entry.getValue().getDoubleValue()); else if(entry.getValue().isBoolean()) jj.addProperty(fieldName,entry.getValue().getBooleanValue()); + else if(entry.getValue().isNull()) + jj.add(fieldName,null); + else if(entry.getValue().isArray()) + jj.add(fieldName,entry.getValue().getArrayValue()); } } @@ -160,6 +167,9 @@ else if(entry.getValue().isDouble()) doomed.add(entry.getValue().getDoubleValue()); else if(entry.getValue().isBoolean()) doomed.add(entry.getValue().getBooleanValue()); + + else if(entry.getValue().isArray()) + doomed.add(entry.getValue().getArrayValue()); } jsonReader.endArray(); diff --git a/json-logic-java/src/main/java/com/jsonlogic/ReduceNode.java b/json-logic-java/src/main/java/com/jsonlogic/ReduceNode.java index 1c747e4..c1b32a6 100644 --- a/json-logic-java/src/main/java/com/jsonlogic/ReduceNode.java +++ b/json-logic-java/src/main/java/com/jsonlogic/ReduceNode.java @@ -41,8 +41,8 @@ Result eval(Map data) throws EvaluationException{ nodes.get(1).treeToString(sb); - if(!sb.toString().contains("{\"var\":\"current\"}")||!sb.toString().contains("{\"var\":\"accumulator\"}")) - throw new EvaluationException("reduce operation missing current or accumulator"); + if(!sb.toString().contains("{\"var\":\"accumulator\"}")) + throw new EvaluationException("reduce operation missing accumulator"); Double accumulator=0.0; @@ -54,10 +54,17 @@ Result eval(Map data) throws EvaluationException{ for(int i=0;i