Repository: jsonata-js/jsonata (js)

Issue:
Transform error with null values
Hello,
I believe this is an error:

Input:

```json
{
  "hi": "world",
  "bye": null
}
```

Transform:

```js
$ ~> | ** ["hi"] | {"hello": hi}, ["hi"] |
```

Output with http://try.jsonata.org :

```
u is null
```

Instead, I would expect the following output:

```json
{
  "bye": null,
  "hello": "world"
}
```


Pull request:
check that target is an object before deleting property
Attempted to delete a property from a non-object value. 

Resolves #396 

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>

Patch:
diff --git a/src/jsonata.js b/src/jsonata.js
index 8b03727..d23cfe4 100644
--- a/src/jsonata.js
+++ b/src/jsonata.js
@@ -1317,7 +1317,9 @@ var jsonata = (function() {
                                 };
                             }
                             for (var jj = 0; jj < deletions.length; jj++) {
-                                delete match[deletions[jj]];
+                                if(typeof match === 'object' && match !== null) {
+                                    delete match[deletions[jj]];
+                                }
                             }
                         }
                     }


Test patch:
diff --git a/test/test-suite/groups/transforms/case013.json b/test/test-suite/groups/transforms/case013.json
new file mode 100644
index 0000000..cedd37e
--- /dev/null
+++ b/test/test-suite/groups/transforms/case013.json
@@ -0,0 +1,12 @@
+{
+    "expr": "$ ~> | ** ['hi'] | {'hello': hi}, ['hi'] |",
+    "data": {
+        "hi": "world",
+        "bye": null
+    },
+    "bindings": {},
+    "result": {
+        "hello": "world",
+        "bye": null
+    }
+}
diff --git a/test/test-suite/groups/transforms/case014.json b/test/test-suite/groups/transforms/case014.json
new file mode 100644
index 0000000..053814f
--- /dev/null
+++ b/test/test-suite/groups/transforms/case014.json
@@ -0,0 +1,12 @@
+{
+    "expr": "$ ~> | ** [hi] | {'hello': hi}, ['hi'] |",
+    "data": {
+        "hi": "world",
+        "bye": null
+    },
+    "bindings": {},
+    "result": {
+        "bye": null,
+        "hello": "world"
+    }
+}