Skip to content

Commit

Permalink
Merge pull request #178 from milosimpson/passNullsThru
Browse files Browse the repository at this point in the history
Null input values can now be passed thru Shiftr.
  • Loading branch information
Milo Simpson committed Dec 30, 2015
2 parents 35e9568 + 730767e commit 813cf7f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,12 @@ private enum ExecutionStrategy {
void processMap( ShiftrCompositeSpec spec, Map<String, Object> inputMap, WalkedPath walkedPath, Map<String, Object> output ) {

for( String key : spec.literalChildren.keySet() ) {
Object subInput = inputMap.get( key );

if ( subInput != null ) {
// we know the .get(key) will not return null
// only recurse down if the literalChild is a key in the input map
if ( inputMap.containsKey( key ) ) {

// At this point subInput could be null, and that is ok
Object subInput = inputMap.get( key );
spec.literalChildren.get( key ).apply( key, subInput, walkedPath, output );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public Object[][] getTestCaseUnits() {
{"mergeParallelArrays3_and-filter"},
{"multiPlacement"},
{"objectToArray"},
{"passNullThru"},
{"passThru"},
{"prefixDataToArray"},
{"prefixedData"},
Expand Down
26 changes: 26 additions & 0 deletions jolt-core/src/test/resources/json/shiftr/passNullThru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"input": {
"key": null,
"bunch-O-keys" : {
"a" : null,
"b" : null,
"c" : null
}
},

"spec": {
"key": "value",
"bunch-O-keys" : {
"*" : "values.&"
}
},

"expected": {
"value" : null,
"values" : {
"a" : null,
"b" : null,
"c" : null
}
}
}

0 comments on commit 813cf7f

Please sign in to comment.